我對OAuth Arena和Google ApI非常陌生,但我想在此實現的目標非常簡單。訪問令牌後訪問Google API獲取個人資料
用戶點擊谷歌連接按鈕和我的web服務應該能夠讓所有的用戶資料信息從谷歌服務器:
我已經寫代碼來獲得的accessToken(我還沒有測試它),但是假設工作正常,現在我應該如何讓Google API給我用戶配置文件?我在GoogleConsumer類中看到名爲Get Contacts的靜態函數,但我沒有看到獲取profiledata的任何選項。可能有我缺少的東西?
這裏使用我的代碼,我得到的accessToken:
IConsumerTokenManager tokenManager =
new LocalTokenManager(consumerKey,consumerSecret);
var googleConsumer =
new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager);
var tokenResult = googleConsumer.ProcessUserAuthorization();
return tokenResult.AccessToken;
現在,我如何得到用戶的個人資料出來的嗎?
大家好,我不知道爲什麼enyone還沒有觸及這個問題。如果我缺乏任何信息,請告訴我。基本上,我驚奇地發現,所有這些WebConsumer(GoogleConsumer和TwitterConsumer)都具有getContacts,UpdateStatus和PostBlog等所有複雜功能,但沒有像GetProfile這樣的基本功能。我在網上看到的所有示例實際上都會得到USerprofile gy在Google的webservice URL上調用GET,但我沒有看到任何演示如何使用GoogleWebConsume檢索userProfile的內容。是不可能的? – TeaLeave 2012-04-17 19:43:21
不[此SO帖子](http://stackoverflow.com/questions/7130648/get-user-info-via-google-api)回答你的問題? – shrisha 2012-04-18 00:01:27
嗯,這篇文章說我們可以使用https://www.googleapis.com/auth/userinfo.profile作爲範圍。這個範圍恰好適用於哪裏?我是否在RequestAuthorization Call上使用它?因爲我試圖把這個URL放在上面,但它不需要字符串參數。 – TeaLeave 2012-04-18 01:28:11