checkAccountOperation调用imapSession 的方法时出现此错误
错误域 = MCOErrorDomain 代码 = 5 “无法使用当前会话的凭据进行身份验证。” UserInfo={NSLocalizedDescription=无法使用当前会话的凭据进行身份验证。}
这是我的代码:
MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
session.dispatchQueue = self.imapQueue;
session.hostname = @"imap.gmail.com";
session.port = 993;
session.maximumConnections = 2;
session.username = emailAddress; //email address with which I logged in
session.password = nil;
session.OAuth2Token = accessToken; // access Token got in success response of google sign in
session.authType = MCOAuthTypeXOAuth2;
session.connectionType = MCOConnectionTypeTLS;
dispatch_async(self.imapQueue, ^{
MCOIMAPOperation *imapCheckOp = [session checkAccountOperation];
[imapCheckOp start:^(NSError *errorResults)
{
NSLog(@"%@",errorResults);
}];
});
我正在使用 google 登录 SDK 登录到 google 帐户
self.googleSignIn = [GIDSignIn sharedInstance];
self.googleSignIn.delegate = self;
self.googleSignIn.uiDelegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource: @"GoogleService-Info" ofType: @"plist"];
NSMutableDictionary *googleDictplist =[[NSMutableDictionary alloc] initWithContentsOfFile:path];
NSString *googleClientId = [NSString stringWithFormat:@"%@",[googleDictplist objectForKey:@"CLIENT_ID"]];
self.googleSignIn.clientID = googleClientId;
[self.googleSignIn signIn];
对于同一问题,我已经尝试了几乎所有从网上获得的可能解决方案。我在 Google Developer 控制台下为我的项目启用了所有需要的 API。即使我在创建 imapSession 时提供了密码,这个问题仍然存在。在我将登录更新为使用最新谷歌登录 SDK 的方式后开始面临这个问题。