0
GAEアプリケーションからFirebase DBにアクセスする際に問題があります。ローカルで実行していてもGAE(* .appspot.com)にデプロイされていれば、Firebaseから不正なエラーが返されます。おそらく私が逃したいくつかの明白なことがあります...Google App EngineからFirebase DBにアクセスする
これは私が使用する_get_http()関数です。これは、(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
私はFirebaseから取り戻すエラーは次のとおりです。
{u'error': u'Unauthorized request.'}
GAEからのログが見え
この含まれています:
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)