'Log in to a GMail account using OAuth 2.0 error
I use this code to login to gmail using oauth 2.o:
var clientSecrets = new ClientSecrets
{
ClientId = "xxx-xxxlpoimr2lrvo2.apps.googleusercontent.com"
// ClientSecret = "XXX"
};
var codeFlow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
// Cache tokens in ~/.local/share/google-filedatastore/CredentialCacheFolder on Linux/Mac
DataStore = new FileDataStore("CredentialCacheFolder", false),
Scopes = new[] { "https://mail.google.com/" },
ClientSecrets = clientSecrets
});
var codeReceiver = new LocalServerCodeReceiver();
var authCode = new AuthorizationCodeInstalledApp(codeFlow, codeReceiver);
var credential = await authCode.AuthorizeAsync(Chatting.Setings.CSetings.email, CancellationToken.None);
if (authCode.ShouldRequestAuthorizationCode(credential.Token))
await credential.RefreshTokenAsync(CancellationToken.None);
var oauth2 = new SaslMechanismOAuth2(credential.UserId, credential.Token.AccessToken);
I get error:
Monday 2022-05-09 11:14:40 EmailParser OpenPop3 Failed to launch browser with "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=xxxxxxhlpoimr2lrvo2.apps.googleusercontent.com&redirect_uri=http%3A%2F%2F127.0.0.1%3A45169%2Fauthorize%2F&scope=https%3A%2F%2Fmail.google.com%2F" for authorization. See inner exception for details.
Monday 2022-05-09 11:14:40 EmailParser OpenPop3 Cannot find the specified file
What's the problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
