【问题标题】:Error Domain=MCOErrorDomain Code=5 "Unable to authenticate with the current session's credentials."错误域 = MCOErrorDomain 代码 = 5 “无法使用当前会话的凭据进行身份验证。”
【发布时间】:2017-09-22 01:07:21
【问题描述】:

我在为 imapSession 调用 checkAccountOperation 方法时收到此错误

Error Domain=MCOErrorDomain Code=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 的方式后开始面临这个问题。

【问题讨论】:

    标签: ios objective-c google-signin mailcore2 gidsignin


    【解决方案1】:

    您没有为 google 登录实例提供任何范围。尝试添加相同的范围

    self.googleSignIn.scopes = [NSArray arrayWithObjects:@"https://www.googleapis.com/auth/userinfo.profile" ,@"https://www.googleapis.com/auth/userinfo.email", @"https://mail.google.com",@"https://www.google.com/m8/feeds/", nil];
    

    【讨论】:

    • 好的会试试
    • 成功了,非常感谢。你救了我。过去 2 天我一直陷入这个问题
    猜你喜欢
    • 2015-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-24
    相关资源
    最近更新 更多