2017-04-25 6 views
1

imapSessionエラードメイン= MCOErrorDomainコード= 5 "現在のセッションの資格情報で認証できません。

エラードメイン= MCOErrorDomainコード= 5のためcheckAccountOperationメソッドを呼び出している間、私はこのエラーを取得しています「現在のセッションの資格情報を使用して認証できません。」 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の作成中にパスワードを与えても、この問題は解決されません。最新のGoogleログインSDKを使用する方法にサインインを更新した後、この問題に直面しました。

答えて

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]; 
+0

これを試してみてください。 – Arun

+0

ありがとうございます。あなたは私を救いました。私はこの問題で過去2日間立ち往生した – Arun

関連する問題