-
Hello, sorry to bother you, but I have a problem with MailKit. I'm getting a MailKit.Security.AuthenticationException error: 'Authentication failed.' It occurs on the line where there is await client.AuthenticateAsync(oauth2);. Note that in oauth2, there is var oauth2 = new SaslMechanismOAuth2("*******@outlook.com", authToken.AccessToken);. So, should I remove the string or find another solution? Thanks for following along so far and I used the code from this link: https://github.com/jstedfast/MailKit/blob/master/ExchangeOAuth2.md#authenticating-a-web-service-with-oauth2. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
As far as I know, there's no reason you can't use a hard-coded string for the username. I don't know why authentication is failing for you. If you followed all of the steps, it should be working. Unfortunately, this is not an issue that I'm equipped to help you debug if it doesn't work. You might have to reach out to the Microsoft Office365 team to help diagnose what the issue is. They'd likely be able to track telemetry log data to pinpoint what went wrong. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. It's nice of you to take the time to reply. I will try to contact Microsoft. For now, the only code I've followed is this :
Would I have by chance made a mistake in the above code? |
Beta Was this translation helpful? Give feedback.
I found the solution with the AcquireTokenByUsernamePassword function thank for help @jstedfast