Created
September 5, 2012 06:05
-
-
Save vadimii/3631357 to your computer and use it in GitHub Desktop.
Recieve Google Auth Refresh Token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CLIENT_ID = "<YOUR CLIENT ID>"; | |
var CLIENT_SECRET = "<YOUR CLIENT SECRET>"; | |
var provider = new NativeApplicationClient( | |
GoogleAuthenticationServer.Description, | |
CLIENT_ID, | |
CLIENT_SECRET); | |
IAuthorizationState state = new AuthorizationState(new[] { | |
"https://www.googleapis.com/auth/drive", | |
"https://www.googleapis.com/auth/userinfo.email" | |
}); | |
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl); | |
var authUri = provider.RequestUserAuthorization(state); | |
var authUriString = authUri.ToString(); | |
Clipboard.SetText(authUriString); | |
Console.Write( | |
"Go to: {1}{1}{0}{1}{1}Then recieve and paste{1}", | |
authUriString, | |
Environment.NewLine); | |
Console.Write("Authorization Code: "); | |
var authCode = Console.ReadLine(); | |
state = provider.ProcessUserAuthorization(authCode, state); | |
Clipboard.SetText(state.RefreshToken); | |
Console.Write("Your refresh token is: {0}", state.RefreshToken); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows.Forms; | |
using DotNetOpenAuth.OAuth2; | |
using Google.Apis.Authentication.OAuth2; | |
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment