How to get credentials in Google AppEngine Python3

2019-07-11 19:50发布

问题:

I started new app in AppEngine Python3.7 stadard.

I am trying to get credentials using the following snippet, but its failing.

Anybody able to get credentials in GAE standard Python37 ?

Input:

from google.auth import app_engine
credentials = app_engine.Credentials()

Output:

The App Engine APIs are not available

回答1:

When using App Engine Standard with python 3.7, none of the google.xxx libraries are available. You have to build your own, or use standard Python libraries. This goes for: auth, users, images, search, mail, taskqueue, memcache, urlfetch, deferred, etc., and even the ndb datastore interface.

For datastore, you use google-cloud-datastore or some 3rd party.

For others, you use a standard Python library, e.g.: google.auth => rauth, google.appengine.api.memcache => python-memcached

Read more here: https://cloud.google.com/appengine/docs/standard/python3/python-differences

That page recommends Google Identity Platform or Firebase Authentication to do authorization.