同步Cognito

时间:2016-10-30 19:22:14

标签: ios objective-c amazon-web-services twitter amazon-cognito

我正在尝试使用外部提供商 - Twitter对AWSCognito进行身份验证。这是我在Twitter上进行身份验证的代码:

[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
}];

这是我在登录时向凭证提供商提供的内容:

- (AWSTask<NSDictionary<NSString *, NSString *> *> *) twitterLogin {

    __block id<TWTRAuthSession> session = nil ;

    session = [((Twitter*)[Twitter sharedInstance]).sessionStore session];

    NSString* token = session.authToken;
    NSString* tokenSecret = session.authTokenSecret;

    NSString* login = [NSString stringWithFormat:@"%@;%@", token, tokenSecret];
    return [AWSTask taskWithResult: @{ AWSIdentityProviderTwitter : login }];
}   

授权后,我在[self.credentialsProvider isAuthentificated]的结果中得到YES 但是当我尝试在Cognito Dataset上进行同步时,我收到一个错误:Error Domain=com.amazonaws.AWSCognitoSyncErrorDomain Code=0 "null" UserInfo={NSLocalizedDescription=null, NSLocalizedFailureReason=AccessDeniedException:} 那是我的IAM认证角色:

{
        "Effect": "Allow",
        "Action": [
            "cognito-identity:*"
        ],
        "Resource": "arn:aws:cognito-identity:us-east-1:198578192657:identitypool/us-east-1:ccb1a09f-5bb7-42af-8ef2-3dede074be38"
    },
    {
        "Effect": "Allow",
        "Action": [
            "cognito-sync:*"
        ],
        "Resource": "arn:aws:cognito-sync:us-east-1:198578192657:identitypool/us-east-1:ccb1a09f-5bb7-42af-8ef2-3dede074be38/identity/*/dataset/*"
    }

怎么了?为什么我会收到错误?

0 个答案:

没有答案