I have successfully integrated Amplify into my project. This has helped me to sign up, sign In and also sign out. Now I need a way to retrieve the Cognito token so I can use it to make api calls with in my app. Unfortunately that hasn’t worked I get the bellow error when I try to cast my session from my Amplify.Auth.fetchAuthSession method. And also I’m able to get the isSignedIn status. > cast session Optional(AmplifyPlugins.AWSAuthCognitoSession(isSignedIn: true, userSubResult: Swift.Result<Swift.String, Amplify.AuthError>.failure(AuthError: Unexpected error occurred with message: An unknown error occurred Recovery suggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at
Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=5 “(null)” UserInfo={__type=InvalidIdentityPoolConfigurationException, message=Invalid identity pool configuration. Check assigned IAM roles for this pool.}), identityIdResult: Swift.Result<Swift.String, Amplify.AuthError>.failure(AuthError: Unexpected error occurred with message: An unknown error occurred Recovery suggestion: This should not happen.
Amplify.Auth.fetchAuthSession { result in
do {
let session = try result.get()
print(session.isSignedIn)
let castSession = session as? AWSAuthCognitoSession
print("cast session ", castSession)
if let cognitoTokenProvider = session as? AuthCognitoTokensProvider {
let tokens = try cognitoTokenProvider.getCognitoTokens().get()
print("Token ", tokens)
}
} catch {
print(error.localizedDescription)
}
}
The isSignedIn value is true. the catch exception is thrown when I try to cast and retrieve the Cognito token