1

我有一個應用程序使用Google Contacts API https://developers.google.com/google-apps/contacts/v3/通過gdata訪問用戶 聯繫人。 我正在使用gdata庫訪問它,並使用OpenID + OAuth1登錄並請求授權 。 谷歌最近做了一些修改,現在規定:Google聯繫人API + API密鑰+ OAuth = 401客戶端錯誤

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. 

如何設置沿着一側的API密鑰GDATA要求? (假設oAuth令牌都被照顧)?

我已經試過:

query = gdata.contacts.service.ContactsQuery(params={'key':'MY_API_KEY'}) 
query.max_results = 200 
feed = googleintegration.contacts_service.GetContactsFeed(query.ToUri()) 

但我總是得到一個401客戶端錯誤。

回答

0

我強烈建議您退出OAuth 1地獄並切換到OAuth 2.0。 OAuth 1已被棄用,原因很充分。