I'm writing a basic app that prints out projects in Google's Cloud Resources Manager using this method: https://cloud.google.com/resource-manager/reference/rest/v1/projects/list
Yesterday it worked but I revoked the token and the code doesn't prompt to re-authorize.
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)
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.
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 ;)