pbr-ayct-backend/ayct_backend/firebase.py

16 lines
435 B
Python
Raw Permalink Normal View History

2022-01-31 18:29:20 +01:00
import os
import google.oauth2.id_token
import google.auth.transport.requests
HTTP_REQUEST = google.auth.transport.requests.Request()
AUDIENCE = os.environ.get('GOOGLE_CLOUD_PROJECT')
def verify_token(headers):
2022-01-31 18:49:47 +01:00
id_token = headers['Authorization'].split(' ').pop()
2022-01-31 18:29:20 +01:00
2022-01-31 19:10:21 +01:00
try:
claims = google.oauth2.id_token.verify_firebase_token(id_token, HTTP_REQUEST, audience=AUDIENCE)
except:
return None
2022-01-31 18:29:20 +01:00
return claims