使用Python gdata API从Google联系人检索任何内容时出现错误400



刚刚开始使用gdata(Python)。令人惊讶的是,在正确设置凭据后,每当我尝试检索所有文件时,我都会得到HTTP代码400。看看这个代码:

s = 'https://www.google.com/m8/feeds'
s = 'https://www.google.com/m8/feeds/contacts/default/full/'
client_secret = CLIENT_SECRET
client_id = CLIENT_ID
client = gdata.contacts.client.ContactsClient()
auth2token = gdata.gauth.OAuth2Token(
        client_id = client_id,
        client_secret = client_secret,
        scope = s,
        user_agent = "bla")
auth2token.authorize(client)
try:
    feed = client.get_contacts()
except gdata.client.RequestError as e:
    print e.args
    print e.body
    print e.headers
    print e.message
    print e.reason
    print e.status

不幸的是,无论s的值是多少,我总是会出错

('Server responded with: 400, ',)
[('alternate-protocol', '443:quic,p=0.08'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('transfer-encoding', 'chunked'), ('accept-ranges', 'none'), ('expires', 'Fri, 01 Jan 1990 00:00:00 GMT'), ('vary', 'Accept-Encoding'), ('server', 'GSE'), ('pragma', 'no-cache'), ('cache-control', 'no-cache, no-store, max-age=0, must-revalidate'), ('date', 'Tue, 03 Mar 2015 02:12:08 GMT'), ('x-frame-options', 'SAMEORIGIN'), ('content-type', 'application/json')]
Server responded with: 400, 
Bad Request
400

有线索吗?

谢谢!

我怀疑问题可能在于重新身份验证,即此流:

  1. 你允许你的应用访问
  2. 也许你没有保存代币
  3. 如果你这次再次允许已经允许的应用程序访问,则保存令牌

使用(3)中的令牌的令牌给我一个400的错误。但是,如果I:

  1. 转到我的谷歌帐户并取消我的本地应用程序和联系人之间的连接
  2. 在本地删除所有令牌,然后重新进行身份验证,似乎可以正常工作

相关内容

最新更新