("Unexpected credential types", "None", "Expected", "service_account") with oauth2client (Python)

I am trying to get Google Analytics data with this guide: https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/

def get_access_token(request): return {'access_t': ServiceAccountCredentials.from_json_keyfile_name( KEY_FILEPATH, SCOPE).get_access_token().access_token } 

With the above code, I am trying to create a function and return the access token to the context in my admin template.

But. I get this error, I don’t know what to do with it:

 ('Unexpected credentials type', None, 'Expected', 'service_account') 

What could be the problem?

+6
source share
2 answers

I also resorted to this. The fix in my case was to use the correct json file. I needed to use the one that was saved when I created the service account key, and not the one with the service account client:

Developer API Console Interface

Hope this helps!

+10
source

This looks like a sample in google-api-python-client is entitled

google-api-python-client / tree / master / samples / analytics

0
source

All Articles