I found a similar question on here, but it was for JavaScript and I am using Python. I'm trying to use the Firebase-Admin SDK so I can verify Firebase Authentication id_tokens in my cloud function. In my requirements.txt I have included firebase-admin, and my main.py file looks like this:
from firebase_admin import auth
from firebase_admin import credentials
def returnSQLresponse(request):
default_app = firebase_admin.initialize_app()
headers = request.headers
if headers and 'Authorization' in headers:
id_token = headers['Authorization']
decoded_token = auth.verify_id_token(id_token)
uid = decoded_token['uid']
There are probably other problems with the above code, but my main issue is I am getting the error "in returnSQLresponse default_app = firebase_admin.initialize_app() NameError: name 'firebase_admin' is not defined". How do I initialize the Firebase Admin SDK in Python so I can verify this token? I tried following the guide here: https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_the_firebase_admin_sdk. This guide lead me to where I am at now.