Problem (Authentication failed):
Initially Gmail authentication through Chilkat failed and after analyzing we found that we have to turn ON "allow less secure apps" for the Gmail account to login successfully.
Proposed Solution by Chilkat:
To avoid turning ON "allow less secure apps" in every Gmail account, we followed solution provided at GMail OAuth2 example
Please find the detailed steps we followed and error code below and help us to resolve this:
1) We created a certificate file(.p12).
Through the service account(in developer console) and we have the service account email address as well.
2) I am able to generate accesstoken successfully.
NSString *accessToken = [http G_SvcOauthAccessToken: iss scope: scope subEmail: sub numSec: [NSNumber numberWithInt: numSec] cert: cert];
3) Connecting to "imap.gmail.com mail" server succeeded.
success = [imap Connect: @"imap.gmail.com"];
4) But when I try to authenticate to gmail account using any gmail ID the authentication fails.
success = [imap Login: @"user@gmail.com" password: accessToken];