0

Today my oauth token is expired but I am unable to regenerate it.

I have a command line tool to interact with the data store on Google Cloud Platform to carry out some support tasks.

Here are the lines of the code that is responsible for the connection

from google.appengine.ext.remote_api import remote_api_stub
remote_api_stub.ConfigureRemoteApiForOAuth(app_name, '/_ah/remote_api')

It prints out these error messages:

INFO:oauth2client.client:Attempting refresh to obtain initial access_token
INFO:oauth2client.client:Refreshing access_token
INFO:oauth2client.client:Failed to retrieve access token: {
  "error" : "invalid_grant"
}
INFO:google.appengine.tools.appengine_rpc:Got access token error
Traceback (most recent call last):
  File "/usr/local/google_appengine/google/appengine/tools/appengine_rpc_httplib2.py", line 247, in Send
    url, method=method, body=payload, headers=headers)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 547, in new_request
    self._refresh(request_orig)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 775, in _refresh
    self._do_refresh_request(http_request)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client/oauth2client/client.py", line 840, in _do_refresh_request
    raise AccessTokenRefreshError(error_msg)
AccessTokenRefreshError: invalid_grant
Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.apis+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=None&access_type=offline

Enter verification code: 

and it follows by a url which it asks me to open in a browser.

When I copy and paste it in chrome, it is all I get

enter image description here

So I tried to run gcloud auth login again. I granted all the access it requested. It seems to work fine.

But when rerun my command line tool, it give the same error message.

So how can I regenerate this 'verification code'?

Anthony Kong
  • 37,791
  • 46
  • 172
  • 304

1 Answers1

1

This fixed my problem

https://stackoverflow.com/a/40493992/58129

Run

 gcloud auth application-default login --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email  
Community
  • 1
  • 1
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304