Click here to Skip to main content
15,885,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to get user profile details from gmail using OAuth for that am using DotNetOpenAuth.dll for OAuth authentication from gmail , its hitting the google login for authentication and redirect to my site correctly but I don't know how to catch that access token.

For Reference here is the link

OAuth 2.0 with Gmail over IMAP for web applications[^].

If anybody having some other ideas please help me am waiting.
If anybody having sample for that it will more helpful.

Thank you
Posted
v2

1 solution

If you go through the link you have provided, the solution is there itself.
It says like below...

After this step user is redirected back to your website (http://www.yourdomain.com/oauth2callback). Following is this callback code. Its purpose is to get a refresh-token and an access-token:
C#
WebServerClient consumer= new WebServerClient(server, clientID, clientSecret);
consumer.ClientCredentialApplicator =
    ClientCredentialApplicator.PostParameter(clientSecret);
IAuthorizationState grantedAccess = consumer.ProcessUserAuthorization(null);

string accessToken = grantedAccess.AccessToken;

An access token is usually valid for a maximum of one hour, and allows you to access the user’s data. You also received a refresh token. A refresh token can be used to request a new access token once the previous expired.
Sample Project links -
Refer dotnetopenid / samples / OAuthConsumer / GoogleAddressBook.aspx.cs[^] for sample page and dotnetopenid / samples / OAuthConsumer[^] for full project.
Thanks...
 
Share this answer
 
v2
Comments
arunraju 14-Dec-12 6:13am    
I need Some sample code for that ,
I have added two sample project links.
Check them out please.
Thanks...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900