【问题标题】:Google contacts API 401 error RestClient::UnauthorizedGoogle 联系人 API 401 错误 RestClient::Unauthorized
【发布时间】:2013-05-15 17:42:46
【问题描述】:

我想使用 Restclient 从 Ruby on rails 中的用户那里检索 Google 联系人,但每次尝试时,我的查询行都会遇到 Restclient 401 Unauthorized 错误。我认为我的查询是错误的或错过了什么,但我没有在 Google Contact API 文档中找到任何有用的东西。 有什么想法吗?

这是我的范围

scope = 'https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.google.com/m8/feeds/contacts/default/full/+https://mail.google.com/mail/feed/atom/+https://www.googleapis.com/auth/calendar'

这是我用新收到的 access_token 调用的方法

def import_google_contact(user_email, access_token)
  r = RestClient.get "https://www.google.com/m8/feeds/contacts/#{user_email}/full?access_token=#{access_token}"
  ...
end

这很奇怪,因为我之前设法使用此请求以相同的方法获取用户电子邮件

r = RestClient.get "https://www.googleapis.com/oauth2/v2/userinfo?access_token=#{access_token}"

【问题讨论】:

    标签: ruby-on-rails ruby


    【解决方案1】:

    我发现我没有在请求联系人数据的范围内放置正确的参数?我把它换成了

    https://www.google.com/m8/feeds
    

    这很奇怪,因为 Google 在授权过程中接受了一个错误

    【讨论】:

      猜你喜欢
      • 2017-01-12
      • 1970-01-01
      • 2013-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多