用于联系人的Python上Google API的OAuth2

用于联系人的Python上Google API的OAuth2,python,google-api-python-client,Python,Google Api Python Client,好的,我在这里遵循了答案: 但是,当我运行测试时,我得到以下结果: oauth2client.client.AccessTokenRefreshError:访问被拒绝 这是我的密码: class OAuthToken(): def __init__(self, creds): self.creds = creds def modify_request(self, req): if self.creds.access_token_expired or not self.creds

好的,我在这里遵循了答案:

但是,当我运行测试时,我得到以下结果:

oauth2client.client.AccessTokenRefreshError:访问被拒绝

这是我的密码:

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安全性中添加了一个或多个API作用域,但这似乎没有帮助


我可能会错过什么?

一封小信就足以让人惊叹

即使身份验证路径为,凭据的实际路径也必须为

业余的错误。对不起,伙计们