Aws-sdk-ios: awscognitoauthclienterror check always fails

Created on 16 May 2020  路  2Comments  路  Source: aws-amplify/aws-sdk-ios

bug mobile client

Most helpful comment

Yes, now when the user's token is completely invalid, requesting the getTokens method will trigger an errorExpiredRefreshToken(-7000) error. At that time, as mentioned above, this conversion method will always fail, resulting in our listeners never having the opportunity to get signedOutUserPoolsTokenInvalid notification.

The right code should be like below:

if let error = error, let cognitoError = AWSCognitoAuthClientErrorType(rawValue: (error as NSError).code) {
    if cognitoError == AWSCognitoAuthClientErrorType.errorExpiredRefreshToken {
        ...
    } else {
        ...
    }
}

All 2 comments

Yes, now when the user's token is completely invalid, requesting the getTokens method will trigger an errorExpiredRefreshToken(-7000) error. At that time, as mentioned above, this conversion method will always fail, resulting in our listeners never having the opportunity to get signedOutUserPoolsTokenInvalid notification.

The right code should be like below:

if let error = error, let cognitoError = AWSCognitoAuthClientErrorType(rawValue: (error as NSError).code) {
    if cognitoError == AWSCognitoAuthClientErrorType.errorExpiredRefreshToken {
        ...
    } else {
        ...
    }
}

Thank you for reporting the issue. I have added a PR to address this issue here - https://github.com/aws-amplify/aws-sdk-ios/pull/2739

Was this page helpful?
0 / 5 - 0 ratings