我正在将AWS Cognito Federated ID与我的iOS应用程序一起用于社交提供商(Facebook,Google)。用Facebook登录后,用户收到错误' 令牌不是来自此身份池的受支持提供商'。如果我在Fed ID中允许未经身份验证的ID,则该用户在Identity浏览器中获取未经身份验证的用户ID(链接登录= 0)并获取会话密钥等。 任何人都可以帮忙解决这个问题吗?
请不要将此问题标记为重复,因为我已经看到所有类似的问题,并按照那里的解决方案进行,但无济于事!
简要介绍代码:
我创建了一个社交ID提供程序类,它实现了AWSIdentityProviderManager协议。该类包含给定的登录方法:
$('#clickable').on('click', function first_click () {
alert("first was clicked");
$("#clickable").off('click', first_click);
$('#clickable').on('click', function second_click () {
alert("second was clicked");
// need to have functionality so on the first click will alert("first was clicked"), on the second click will alert("second was clicked"), on the third click will alert("first was clicked"), on fourth click will alert("second was clicked") and so on...
});
});
我的登录视图控制器执行FB登录。它通过将socialIDProvider类作为identityProvider传递给它构建fbCredentialsProvider,实现如下:
(AWSTask<NSDictionary<NSString *, NSString *> *> )logins {
FBSDKAccessToken fbToken = [FBSDKAccessToken currentAccessToken];
if(fbToken){
NSString *token = fbToken.tokenString;
return [AWSTask taskWithResult: @{ AWSIdentityProviderFacebook : token }];
} else {
NSLog(@"FB Token is not found in AWSSocialIdentityProvider class");
return [AWSTask taskWithError:[NSError errorWithDomain:@"facebook"
code:-1
userInfo:@{@"error":@"No current Facebook access token"}]];
}
}
//用于调用fb登录 [self.fbCredentialsProvider凭证];
上面的代码在FB Login Button的didCompleteWithResult方法中调用。 那就是它。