Skip to content

Commit

Permalink
Updated GMailOAuth2.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Jul 12, 2020
1 parent 5288273 commit 5a67ad6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion GMailOAuth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ var codeFlow = new GoogleAuthorizationCodeFlow (new GoogleAuthorizationCodeFlow.
ClientSecrets = clientSecrets
});

// Note: For a web app, you'll want to use AuthorizationCodeWebApp instead.
var codeReceiver = new LocalServerCodeReceiver ();
var authCode = new AuthorizationCodeInstalledApp (codeFlow, codeReceiver);

var credential = await authCode.AuthorizeAsync (GMailAccount, CancellationToken.None);

if (authCode.ShouldRequestAuthorizationCode (credential.Token))
if (credential.Token.IsExpired (SystemClock.Default))
await credential.RefreshTokenAsync (CancellationToken.None);

var oauth2 = new SaslMechanismOAuth2 (credential.UserId, credential.Token.AccessToken);
Expand Down

0 comments on commit 5a67ad6

Please sign in to comment.