0
好吧,我跟着這裏的答案: Is it possible to use "Domain-wide Delegation of Authority" with gdata-python-client?OAuth2以Python的谷歌API連絡
然而,當我跑我的測試,我得到這樣的:
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('[email protected]',\
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 &憑據正確設置。
I did將https://www.google.com/m8/feeds/添加到我在API安全中的「一個或多個API範圍」中,但這似乎沒有幫助。
我可能會丟失什麼?