Reputation: 16298
I am having trouble accessing Firebase DB from a GAE app. It works fine when running locally, but deployed to GAE (*.appspot.com) I get an unauthorized error back from Firebase. There is likely some obvious thing I missed...
This is the _get_http() function I use. It works fine (after doing gcloud beta auth application-default login
)
def _get_http():
_FIREBASE_SCOPES = [
'https://www.googleapis.com/auth/firebase.database',
#'https://www.googleapis.com/auth/userinfo.email'
]
"""Provides an authed http object."""
http = httplib2.Http()
# Use application default credentials to make the Firebase calls
# https://firebase.google.com/docs/reference/rest/database/user-auth
creds = GoogleCredentials.get_application_default().create_scoped(_FIREBASE_SCOPES)
creds.authorize(http)
return http
The error I get back from Firebase is:
{u'error': u'Unauthorized request.'}
The log from GAE looks includes this:
11:14:43.835
Attempting refresh to obtain initial access_token
11:14:44.625
Refreshing due to a 401 (attempt 1/2)
11:14:44.966
Refreshing due to a 401 (attempt 2/2)
Upvotes: 0
Views: 162
Reputation: 16298
Got it! I had commented out 'https://www.googleapis.com/auth/userinfo.email'
thinking it was unnecessary. Wrong. Enabling it again, bingo!
Upvotes: 1