Google Plus Domains API AccessTokenRefreshError

时间:2013-08-16 00:41:20

标签: google-api google-plus google-apps google-api-python-client google-admin-sdk

我正在尝试使用Google+域名API为我的Google Apps域配置圈子。我按照https://developers.google.com/+/domains/authentication/delegation使用了域范围的委派,我已成功用于组,用户和日历配置。在API控制台中,我已将Google+ API和Google+域名API添加到API项目中。我已经尝试使用预先存在的密钥,并生成一个新密钥。当我尝试运行以下代码时:

service_account_email='somelongstring@developer.gserviceaccount.com'
key=file("path/to/keyfile","rb").read()
user_email='someroleaccount@mydomain.com'
SCOPES_PLUS = [
  'https://www.googleapis.com/auth/plus.me',
  'https://www.googleapis.com/auth/plus.stream.write',
]
credentials = SignedJwtAssertionCredentials(service_account_email, key,
                                            scope=SCOPES_PLUS, sub=user_email)
http = httplib2.Http()
http = credentials.authorize(http)
plus = build(serviceName='plus', version='v1domains', http=http)

我得到了

AccessTokenRefreshError: access_denied

当它遇到build()调用时。

但是,完全相同的代码(具有不同的范围和服务)适用于目录服务,groupssettings服务和日历服务。

我已尝试将角色帐户作为子电子邮件地址,并作为我自己的(超级管理员)帐户。

有什么想法吗?

2 个答案:

答案 0 :(得分:2)

您是否记得在域控制面板中为新作用域授予服务帐户授权?流程is described in the Drive documentation。请务必输入Google Plus域名范围以及目录和群组设置范围,因为任何更改都会覆盖您现有的授权。

答案 1 :(得分:1)

我编写了一个教程,在Google App Engine上使用新的G + Domains API和Python,它逐步解释了每个必要的配置,并提供了一些示例代码:

https://gist.github.com/vircheck/6292176

另外,请不要忘记官方的快速启动here,但请记住,这个不适用于App Engine。