I am trying to access a google sheet via python. So far, all the authentication and verification with my Google Account worked. But according to http://www.indjango.com/access-google-sheets-in-python-using-gspread/
storage=Storage('creds.data')
should create a file from which I can access the refresh_token. When executing my code however, after I get the The authentication flow has completed message in my Google Chrome, no file is being stored. Here is my code
from oauth2client.client import OAuth2WebServerFlow
from oauth2client import tools
from oauth2client.file import Storage
CLIENT_ID = '<Client ID from Google API Console>'
CLIENT_SECRET = '<Client secret from Google API Console>'
flow = OAuth2WebServerFlow(
client_id = "contains my id",
client_secret = "contains my secret",
scope = 'https://spreadsheets.google.com/feeds https://docs.google.com/feeds',
redirect_uri = 'http://example.com/auth_return'
)
storage = Storage('creds.data')
flags = tools.argparser.parse_args(args=[])
credentials = tools.run_flow(flow, storage, flags)
print("access_token: %s" % credentials.access_token)
Maybe I do not understand the Storage() class correctly? Does anyone know how do resolve that?
EDIT: Timeout error:
Resolved
It turned out, that the cause was the Internet access (probably firewall) at my workplace. Tried to run the code at home and it worked.