我试图创建一个服务帐户应用程序,以便我可以使用Python访问Google Analytics API。 有两件事让我感到困惑。首先,当我使用下面的代码:
使用服务帐户的Google API访问oauth2client.client.CryptoUnavailableError:没有可用的加密库
`from oauth2client.client import SignedJwtAssertionCredentials
client_email = "#####client_email#######.gserviceaccount.com"
with open("XXXXXX.p12") as f:
private_key = f.read()
credentials = SignedJwtAssertionCredentials(client_email, private_key,'https://www.googleapis.com/auth/sqlservice.admin')`
我收到以下错误:
`oauth2client.client.CryptoUnavailableError: No crypto library available`
做一个小小的研究,我发现,这可能与授予应用程序后做全域服务帐户的权限。但是,当我登录Google Developers Console时,找不到安全图标或更多选项按钮。任何帮助非常感谢你。
当'p12'文件转换成'pem'作为@davidtzau介绍你需要输入Google在'notasecret'的'p12'文件上设置的默认密码。当“pem”内容输出到新的“pem”文件时,它不再受密码保护。尽管如此,oauth2client模块在不使用密码的情况下优雅地接受“pem”内容,但默认情况下会假设“notasecret”的密码短语:https://google-api-python-client.googlecode.com/hg/docs/epy /oauth2client.client.SignedJwtAssertionCredentials-class.html – 2014-12-23 06:43:47