Google OAuth2client - invalid_grant: Token has been revoked
<p>I'm writing a basic app that prints out projects in Google's Cloud Resources Manager using this method:
<a href="https://cloud.google.com/resource-manager/reference/rest/v1/projects/list" rel="nofollow">https://cloud.google.com/resource-manager/reference/rest/v1/projects/list</a></p>

<p>Yesterday it worked but I revoked the token and the code doesn't prompt to re-authorize.</p>

<pre><code>from googleapiclient import discovery from oauth2client.client import GoogleCredentials

credentials = GoogleCredentials.get_application_default()

service = discovery.build('cloudresourcemanager', 'v1', credentials=credentials)

projects = service.projects() request = projects.list() while request is not None:

    response = request.execute()

    for project in response['projects']:
        print project
    request = projects.list_next(previous_request=request, previous_response=response)
</code></pre>

<blockquote>
  <p>File "oauth2client/client.py", line 834, in _do_refresh_request
      raise HttpAccessTokenRefreshError(error_msg, status=resp.status) oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Token
  has been revoked.</p>
</blockquote>

<p>I think there's a way to tell the client to check if the token is valid and pop the user out to a browser if not, but can't seem to get the code to do it.  Any help appreciated ;)</p>

<p>Since this code uses application default credentials, the gcloud command is how I get a new token:</p>

<pre><code>gcloud beta auth application-default login
</code></pre>

<p>Although it would be nice if there was a way to do this in code in the event the token is revoked again.</p>

python pycharm google-api-client google-oauth2 oauth2client