Now please find section of below code i am trying to run it gives me Authentication Failure error.
However, the imap is connected. Both the username and accessToken are correct as well.
var app = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantId)
.WithClientSecret(clientSecret)
.Build();
string[] scopes = new string[] { "https://outlook.office365.com/.default openid offline_access" };
var result = await app.AcquireTokenForClient(scopes).ExecuteAsync();
string accessToken= result.AccessToken;
var imap = new Imap();
// server (successfully connected)
imap.ConnectSSL("outlook.office365.com");
// throws an exception here
imap.LoginOAUTH2("username", "accessToken");
Hello support team, I have done the setup as per the documentation. And it works fine from the access token that I received after login which is in below format.
Sample of Access token able to authenticate:
EwBAA+l3BAAUnQP8Jfa2FYxR0AX7HsEZwOdW.... ==
However, on refreshing new access token the format is in base64Url so I convert it to base64 at first. In both format it seems to throw me authentication error. Below is the token format that I received after refreshing.
Sample of Access token unable to authenticate:
eyJ0eXAiOiJKV1QiLCJub25jZSIF3_Aw