Skip to content

Instantly share code, notes, and snippets.

@altendky
Created March 30, 2019 18:19
Show Gist options
  • Save altendky/8922824df4f8c633a85bf60fa23da2e2 to your computer and use it in GitHub Desktop.
Save altendky/8922824df4f8c633a85bf60fa23da2e2 to your computer and use it in GitHub Desktop.
from . import google
dispatch = {
'google': google.validate
}[platform](token)
def get_profile_for_token(client_ids, platform, token):
if platform == 'google' and platform in client_ids:
return google.validate(client_ids[platform], token)
@app.route('/login', methods=['POST'])
def login():
data = request.get_json()
try:
platform = data['platform']
token = data['token']
except IndexError:
return Response(status=400)
profile = oauth.get_profile_for_token(fbf.config.config['oauth_ids'], platform, token)
if profile:
user_id = profile['email']
user = db.Query(fbf.db.User).filter_by(user_id=user_id).first()
if not user:
new_user = fbf.db.User(user_id=user_id)
db.session.add(new_user)
db.session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment