I am trying to get the cognito identity using access tokens that I retrieved from my identity provider. A little bit like in here . There seem to be an issue with this part of the AWS SDK as described here , so I am trying to find a work-around.
When I run the code I am getting the following error:
Task result: nil Error Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Invalid login token. Issuer doesn't match providerName}
Below my code, I suspect that the problem is the way I set up the logins in here:
idInput?.logins = ["provider_url": idToken] // Do I need some other parameter?
Code:
func congitoAuthentication(accessToken : String, idToken : String, refreshToken : String) {
let credentialProvider = AWSCognitoCredentialsProvider(regionType: .EUWest1, identityPoolId: "eu-west-2:XXXX")
let serviceConfig = AWSServiceConfiguration(region: .EUWest1, credentialsProvider: credentialProvider)
AWSServiceManager.default().defaultServiceConfiguration = serviceConfig
let idInput = AWSCognitoIdentityGetIdInput()
idInput?.identityPoolId = "eu-west-2:XXXX"
idInput?.logins = ["provider_url": idToken]
let identity = AWSCognitoIdentity.default()
let task = identity.getId( idInput!).continueWith(block: { (task) -> Any? in
if let error = task.error as? NSError {
print("Error \(error)")
return nil
}
return nil
})
}
your "provider_url" is the type "cognito-idp.xxx"? it seems you are passing an invalid "provider_url"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.