【问题标题】:Google Contacts API + API Key + OAuth = 401 Client errorGoogle 联系人 API + API 密钥 + OAuth = 401 客户端错误
【发布时间】:2013-11-11 22:50:14
【问题描述】:

我有一个使用 Google Contacts API 的应用 https://developers.google.com/google-apps/contacts/v3/通过gdata访问用户 联系人。 我正在使用 gdata 库来访问它,并使用 OpenID+OAuth1 来登录和 请求授权。 谷歌最近做了一些改变,现在声明:

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 客户端错误。

【问题讨论】:

    标签: google-app-engine gdata google-oauth gdata-api google-contacts-api


    【解决方案1】:

    我强烈建议您摆脱 OAuth 1 的地狱并切换到 OAuth 2.0。出于充分的理由,OAuth 1 已被弃用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 2021-05-12
      • 1970-01-01
      • 2014-05-03
      • 2016-03-15
      • 2012-11-24
      • 1970-01-01
      相关资源
      最近更新 更多