我有一个使用Google Contacts API的应用 https://developers.google.com/google-apps/contacts/v3/通过gdata访问用户 联系人。 我正在使用gdata库来访问它,并使用OpenID + OAuth1来登录和 请求授权。 Google最近做了一些更改,现在声明:
Warning: Due to enhanced security measures we've added to our
infrastructure, all developers using the Contacts API must register their
projects in the API Console <https://code.google.com/apis/console> and
ensure the Contacts API is activated in the API Console.
If your application has certain unusual authorization requirements, such aslogging
in at the same time as requesting data access (hybrid<http://code.google.com/apis/accounts/docs/OpenID.html#oauth>
) or domain-wide delegation of authority (2LO<http://code.google.com/apis/accounts/docs/OAuth.html#GoogleAppsOAuth>
), then you cannot currently use OAuth 2.0 tokens.
In such cases, you must instead use OAuth 1.0 tokens and an API key<http://code.google.com/apis/console-help/#WhatIsKey>
. You can find your application's API key in the GoogleAPI Console<https://code.google.com/apis/console#access>,
in the Simple API Access section of the API Access pane.
如何在gdata请求旁边设置API密钥? (假设oAuth令牌都得到了处理)?
我试过了:
query = gdata.contacts.service.ContactsQuery(params={'key':'MY_API_KEY'})
query.max_results = 200
feed = googleintegration.contacts_service.GetContactsFeed(query.ToUri())
但我总是收到401客户端错误。
答案 0 :(得分:0)
我强烈建议您退出OAuth 1地狱并切换到OAuth 2.0。 OAuth 1已被弃用,原因很充分。