I'm trying to get Google Analytics data with this guide: https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/
我正在尝试使用此指南获取Google Analytics数据: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 code above I'm trying to a create a function and return the access token to the context in my admin template.
使用上面的代码,我正在尝试创建一个函数,并将访问令牌返回到我的管理模板中的上下文。
However. I get this error I don't know what to do with:
然而。我收到此错误我不知道该怎么办:
('Unexpected credentials type', None, 'Expected', 'service_account')
What could be the issue here?
这可能是什么问题?
2 个解决方案
#1
13
I too was running in 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, not the one with the service account client:
我也参与其中。在我的情况下修复是使用正确的json文件。我需要使用创建服务帐户密钥时保存的密钥,而不是使用服务帐户客户端密钥的密钥:
Hope that helps!
希望有所帮助!
#2
0
It seams like the sample in google-api-python-client has it right
它接口像google-api-python-client中的样本一样正确
#1
13
I too was running in 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, not the one with the service account client:
我也参与其中。在我的情况下修复是使用正确的json文件。我需要使用创建服务帐户密钥时保存的密钥,而不是使用服务帐户客户端密钥的密钥:
Hope that helps!
希望有所帮助!
#2
0
It seams like the sample in google-api-python-client has it right
它接口像google-api-python-client中的样本一样正确