OAuth20 authentication is failing for Gmail.
Below is the smtpException I am getting:
"OAUTH: Bad authentication request (400)."
Below is the code snippet:
try{
Smtp client = new Smtp();
client.Connect("smtp.gmail.com", SslMode.Implicit);
string accessToken = GetAccessToken();
// which gives the valid access token: ya29.Ci9eAx9cGKj2yV2KJ08v0uGbdE2EhIYPMRW2Vx0Dmzo5sQWP4SfdV2nDdkVDKFZN9Q
// prepare token
string pattern = string.Format("user={0}{1}auth=Bearer {2}{1}{1}", userEmailId, '\x1', accessToken);
string token = Convert.ToBase64String(Encoding.ASCII.GetBytes(pattern));
client.Login(token, SmtpAuthentication.OAuth20);
}
catch(SmtpException ex)
{}
Kindly let me know if there is anything that I am missing out...
Regards
Santosh