0

我創建了Google Apps Marketplace應用程序,並試圖通過調用Google Apps Provisioning API獲取Google應用程序域的所有用戶的列表,但可以「T闖過此錯誤:Google Apps Provisioning API:HTTPBadRequest 400錯誤的請求錯誤

#<Net::HTTPBadRequest 400 Bad Request readbody=true> 

這裏是我使用的代碼:

consumer = OAuth::Consumer.new(my_google.oauth_key, 
           my_google.oauth_secret, 
           :site => 'https://apps-apis.google.com/a/feeds/user/#readonly', 
           :http_method => :get) 
access_token = OAuth::AccessToken.new consumer 
result = access_token.get("https://apps-apis.google.com/a/feeds/my_domain.com/user/2.0?alt=json") 

我也有這個谷歌應用清單文件:

<Scope id="scopeUsers"> 
    <Url>https://apps-apis.google.com/a/feeds/user/#readonly</Url> 
    <Reason>Our App will be setup for your entire domain.</Reason> 
</Scope> 

我已經驗證了oauth_key和secret,並嘗試了很多其他的可能性,但是無法達到這個底部。有什麼我在這裏失蹤?我可以嘗試的其他選項?

回答

0

我想出了這個問題。這是OAuth gem版本的問題,我使用的是OAuth 0.4.6,需要使用OAuth 0.4.5才能與我使用的語法兼容。

1

HTTP響應還包含一個更具描述性的錯誤消息,解釋您的請求無效的原因。我不知道Ruby庫,但必須有方法訪問該字段。 如果沒有,您還可以使用Wireshark或Fiddler等工具來捕獲流量並檢查響應。

+0

感謝Claudio的提示,我剛剛發現了這個問題。這是OAuth gem版本的問題 – ramz15