2013-05-13 89 views
2

我想從使用Restclient的rails上的用戶檢索Google聯繫人,但每次我嘗試時,我都會在我的查詢行上遇到Restclient 401 Unauthorized錯誤。我認爲我的查詢是錯誤的或者是想念一些東西,但我在Google聯繫人API文檔中找不到任何有用的東西。 有什麼想法?谷歌聯繫API 401錯誤RestClient ::未授權

這裏是我的範圍

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}" 

回答

0

我發現我沒有把正確的參數放在請求聯繫人數據的範圍?我取代它由

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

這是奇怪的,因爲谷歌接受在授權過程中一個錯誤的