2

我想使用 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}"
4

1 回答 1

0

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

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

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

于 2013-05-14T17:19:58.500 回答