in app/middlewares/auth.py [0:0]
def verify_firebase_id_token(token):
"""
A helper function for verifying ID tokens issued by Firebase.
See https://firebase.google.com/docs/auth/admin/verify-id-tokens for
more information.
Parameters:
token (str): A token issued by Firebase.
Output:
auth_context (dict): Authentication context.
"""
try:
full_auth_context = auth.verify_id_token(token)
except ValueError:
return {}
auth_context = {
'username': full_auth_context.get('name'),
'uid': full_auth_context.get('uid'),
'email': full_auth_context.get('email')
}
return auth_context