Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GAE: remote_api and Application Default Credentials

Since today i've been using remote_api (python) to access the datastore on GAE.

I usually do remote_api_shell.py -s <mydomain>.

Today I tried and it fails, the error is:

oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

I cannot understand why it asks me that.

the wole output is this

stefano@~/gc$ remote_api_shell.py -s ....
Traceback (most recent call last):
  File "/usr/local/bin/remote_api_shell.py", line 133, in <module>
    run_file(__file__, globals())
  File "/usr/local/bin/remote_api_shell.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 157, in <module>
    main(sys.argv)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 153, in main
    appengine_rpc.HttpRpcServer)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 74, in remote_api_shell
    secure=secure)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 734, in ConfigureRemoteApiForOAuth
    credentials = client.GoogleCredentials.get_application_default()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 1204, in get_application_default
    return GoogleCredentials._get_implicit_credentials()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 1194, in _get_implicit_credentials
    raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
like image 494
EsseTi Avatar asked Dec 25 '22 14:12

EsseTi


2 Answers

The solution is to run gcloud auth login in the shell and give the grant again

like image 90
EsseTi Avatar answered Jan 12 '23 14:01

EsseTi


  1. Go to the Developers Console under API Manager>>Credentials (currently at https://console.developers.google.com/apis/credentials?project=<<<Your App Id>>>).
  2. Click on the service account, and then on a button that is labeled: "Generate new JSON Key".
  3. A file will be downloaded, save it in a secure place.
  4. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to the file you saved before you run remote_api_shell.py
like image 21
gae123 Avatar answered Jan 12 '23 16:01

gae123