2

I'm using Firebase for the first time and am unable to verify that a user is authenticated from the Firebase idToken.

I've attempted to use Google App Engine's example in flask: https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/firebase/firenotes.

I've also tried using python libraries mentioned by Firebase here: https://jwt.io/

Any help would be greatly appreciated.

1 Answer 1

2

Simply to identify a user you have to send the token that generates javascript as a header in the request to the server

Authorization:key=eyJhbGc .... ZgeFONFh7HgQ    
id_token = request.headers['Authorization'].split('=').pop()

Once you have that token with the library google.oauth2.id_token will ask for the UID of that generated token

claims = google.oauth2.id_token.verify_firebase_token(id_token, HTTP_REQUEST)
If not claims:
         Return 'Unauthorized', 401
UID = claims['sub']

Already with that UID is like your PK in any DB that you use

Sign up to request clarification or add additional context in comments.

4 Comments

That makes sense and is very similar to the google flask example I linked to however I keep getting this error: "from google.appengine.ext import ndb ImportError: No module named appengine.ext"
=>1. Install Gcloud. =>2. gcloud components install app-engine-python =>3. run dev server with "$ dev_appserver.py app.yaml" don't use Windows because dosen't work
Thanks! Had to setup everything on my mac and it finally worked after running 'pip install <dependency> -t lib/' for google-auth==0.7.0, requests==2.13.0, requests-toolbelt==0.7.1
where does HTTP_REQUEST come from?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.