【问题标题】:OAuth2 for Google API on Python for ContactsOAuth2 for Google API on Python for Contacts
【发布时间】: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


    【解决方案1】:

    一个小字母的作用真是太神奇了。

    即使身份验证路径是 http://www.google.com/m8/feeds/,凭据的实际路径也必须是 https://www.google.com/m8/feeds/

    业余错误。对不起各位。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-21
      • 1970-01-01
      • 2013-11-01
      • 2014-08-26
      • 1970-01-01
      • 2018-06-07
      • 2012-05-06
      • 2013-08-18
      相关资源
      最近更新 更多