Click here to Skip to main content
12,400,556 members (58,505 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 13-Dec-12 1:24am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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:
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...
  Permalink  
v2
Comments
arunraju 14-Dec-12 6:13am
   
I need Some sample code for that ,
Tadit Dash 14-Dec-12 6:36am
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100