简体   繁体   English

AWS Amplify iOS cognitoIdentityPoolNotConfigured 错误

[英]AWS Amplify iOS cognitoIdentityPoolNotConfigured error

I am using federated sign in using AWS Amplify SDK.我正在使用 AWS Amplify SDK 进行联合登录。 Following is my awsconfigfile.json以下是我的 awsconfigfile.json

{ "UserAgent": "aws-amplify-cli/0.1.0", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CredentialsProvider": { "CognitoIdentity": { "Default": { "PoolId": "us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "Region": "us-east-1" } } }, "CognitoUserPool": { "Default": { "PoolId": "us-east-1_xxxxxxxxx", "AppClientId": "xxxxxxxxxxxxxxxxxxxxxxxxxx", "AppClientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "Region": "us-east-1" } }, "Auth": { "Default": { "authenticationFlowType": "CUSTOM_AUTH" } } } { "UserAgent": "aws-amplify-cli/0.1.0", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CredentialsProvider": { "CognitoIdentity": { “默认”:{“PoolId”:“us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,“区域”:“us-east-1”}}},“CognitoUserPool”:{“默认” :{“PoolId”:“us-east-1_xxxxxxxxx”,“AppClientId”:“xxxxxxxxxxxxxxxxxxxxxxxxxx”,“AppClientSecret”:“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,“区域”:“us-east-1”}},“Auth”:{“默认”:{“authenticationFlowType”:“CUSTOM_AUTH”}}}

    let awsClient = AWSMobileClient.default()
    
    awsClient.federatedSignIn(providerName: Configuration.current.awsSAMLProvider,
                                              token: token) { (userState, error) in

        if let userState = userState {
            print("Status: \(userState.rawValue)")
            awsClient.getAWSCredentials { creds, error in
                if let creds = creds {
                    onComplete(.success)
                } else if let error = error {
                    
                }
            }
        }
    }

I tried many things but always getting following error "There is no valid cognito identity pool configured in awsconfiguration.json."我尝试了很多事情,但总是收到以下错误“在 awsconfiguration.json 中没有配置有效的认知身份池”。

Adding initialization code in App Delegate fixed this issue在 App Delegate 中添加初始化代码修复了这个问题

    AWSMobileClient.default().initialize { (userState, error) in
        
    }

https://github.com/aws-amplify/aws-sdk-ios/issues/1773 https://github.com/aws-amplify/aws-sdk-ios/issues/1773

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM