【发布时间】:2015-05-27 15:53:41
【问题描述】:
好的,我按照这里的答案: Is it possible to use "Domain-wide Delegation of Authority" with gdata-python-client?
但是当我运行我的测试时,我得到了这个:
oauth2client.client.AccessTokenRefreshError: access_denied
这是我的代码:
class OAuthToken():
def __init__(self, creds):
self.creds = creds
def modify_request(self, req):
if self.creds.access_token_expired or not self.creds.access_token:
self.creds.refresh(httplib2.Http())
self.creds.apply(req.headers)
def ListContacts(username):
file = open('privatekey.pem','rb')
text = file.read()
file.close()
credentials = SignedJwtAssertionCredentials('somelongnumber@developer.gserviceaccount.com',\
text,\
scope=['http://www.google.com/m8/feeds/'],\
prn=username+'@mycompany.com')
gdclient = gdata.contacts.client.ContactsClient(source='mycompany.com')
gdclient.auth_token = OAuthToken(credentials)
feed = gdclient.GetContacts()
我所有的其他 OAuth2 东西都有效,只是联系人让我很伤心,所以我认为我的 API 和凭据设置正确。
我确实在 API 安全性中将https://www.google.com/m8/feeds/ 添加到我的“一个或多个 API 范围”中,但这似乎没有帮助。
我可能缺少什么?
【问题讨论】:
标签: python google-api-python-client