开发者

How to get the Google user ID (email) when using Google Account OAuth API

I am new to OAuth, and want to get the user ID (an email address) from Google using OAuth.

But I don't want to get the user's Google Con开发者_StackOverflow社区tacts Information.


We can get google Email address only not the contacts by making the scope of request token Like :

"https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.googleapis.com/auth/userinfo#email";

Now do a authorized call to get the response like :

var responseText = oAuthConsumer.GetUserInfo("https://www.googleapis.com/userinfo/email", consumerKey, consumerSecret, token, tokenSecret);

Here by saying authorized call mean to make the HTTP Get request with required paramaters in header.

header string should contain: realm, consumerKey, signatureMethod, signature, timestamp, nounce, OAuthVersion, token

Please refer to http://googlecodesamples.com/oauth_playground to verify your code and to see the correct header string parameters

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜