16 lines
435 B
Python
16 lines
435 B
Python
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):
|
|
id_token = headers['Authorization'].split(' ').pop()
|
|
|
|
try:
|
|
claims = google.oauth2.id_token.verify_firebase_token(id_token, HTTP_REQUEST, audience=AUDIENCE)
|
|
except:
|
|
return None
|
|
|
|
return claims |