How to Get credentials from dictionary, not json file #1968
Unanswered
diegocgaona
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm following the example (Google Analytics) to get my credentials and build my service object with the following code and the python SDK:
It works, I get my credentials and it return my "analytics" which works.
But I want to get my credentials from a dictionary (from a DB), not the json.
My dict would be like:
``{"access_token": "ya29.XXXXXXXXXXXXXX-9vw0163", "refresh_token": "1//0fu-XXXXXXXXXXXXXXF-XXXXX", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "000000000000-XXXXX.apps.googleusercontent.com", "client_secret": "GOXXX-XXXXXXXX", "scopes": ["https://www.googleapis.com/auth/analytics.readonly"]}
How I could do that? I can't use the
file.Storage('ga_token.json')
andstorage.get()
I tried:
credentials = google.oauth2.credentials.Credentials(**ga_token)
But the credentials created are not the correct type and I have the error:
AttributeError: 'Credentials' object has no attribute 'authorize'
How I could do that?
Best regards, Diego
Beta Was this translation helpful? Give feedback.
All reactions