I'm trying to create a Credential object using the classmethod from_authorized_user_file()
. I want to use a code and refresh token stored into a file. This is part of my code:
from google.oauth2.credentials import Credentials as cred
new_cred = cred.from_authorized_user_file('data.json')
The data inside data.json
is:
{"token": "1111", "refresh_token": "2222",
"token_uri": "https://oauth2.googleapis.com/token",
"client_id": "3333.apps.googleusercontent.com",
"client_secret": "4444",
"scopes": ["https://www.googleapis.com/auth/youtube.readonly", "https://www.googleapis.com/auth/youtube.force-ssl"]}
And that is the error I got:
/srv/conda/envs/notebook/lib/python3.7/site-packages/six.py in iterkeys(d, **kw)
579 if PY3:
580 def iterkeys(d, **kw):
--> 581 return iter(d.keys(**kw))
582
583 def itervalues(d, **kw):
AttributeError: 'str' object has no attribute 'keys'
I don't know why this is happening, it seems to treat the object as string rather than a json object. Anyone has some clue about this?