I'm using Github-Flask to authenitcate users on my app. I use github.authorize(scope='user:email')
. How can I get the logged in user's email?
github = GitHub(app)
user = None
@app.route('/login')
def login():
if user.username:
return redirect(url_for('index'))
return github.authorize(scope='user:email')
@github.access_token_getter
def token_getter():
if user is not None:
return user.github_access_token
@app.route('/github-callback')
@github.authorized_handler
def authorized(oauth_token):
if oauth_token is None:
flask.flash("Authorization failed.")
return redirect(url_for('index'))
global user
user.username = oauth_token
return redirect(url_for('index'))