Closed Vaibhav43 closed 4 weeks ago
The error says that you don't have any identity pool. Can you share your amplifyconfiguration.json
or amplify_output.json
redacted all the sensitive information .
@harsh62 Please find the file.
awsconfiguration.json
{ "UserAgent": "aws-amplify/cli", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CognitoUserPool": { "Default": { "PoolId": "us-east-1-**********", "AppClientId": "******************************", "AppClientSecret": "**************************************************", "Region": "us-east-1" } }, "Auth": { "Default": { "authenticationFlowType": "USER_SRP_AUTH" } } }
{ "UserAgent": "aws-amplify-cli/2.0", "Version": "1.0", "auth": { "plugins": { "awsCognitoAuthPlugin": { "UserAgent": "aws-amplify/cli", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CognitoUserPool": { "Default": { "PoolId": "us-east-1-**************", "AppClientId": "****************************", "AppClientSecret": "********************************************************", "Region": "us-east-1" } }, "Auth": { "Default": { "authenticationFlowType": "USER_SRP_AUTH" } } } } } }
@Vaibhav43 There is no identity pool configuration. So the error is expected. Can you share your code and use case that you are trying to achieve?
In our case we are using the User Pool.
`{ let session = try await Amplify.Auth.fetchAuthSession(options: .forceRefresh())
// Get cognito user pool token
if let cognitoTokenProvider = session as? AWSAuthCognitoSession {
let tokens = try cognitoTokenProvider.getCognitoTokens().get()
debugPrint("Id token - Id token - \(tokens.idToken)")
debugPrint("Session Id - \(UserDefaultsClass.get(key: .sessionId) as? String ?? "")")
var expirationDate = Date().add(components: [.minute], values: [55])
if let tokenExpirationDate = try? AWSAuthService().getTokenClaims(tokenString: tokens.idToken).get()["exp"]?.doubleValue {
let date = Int64(tokenExpirationDate*1000).toDate
expirationDate = date
}
let isTokenAlreadySaved = UserDefaultsClass.isAvailable(key: .accessToken)
if isTokenAlreadySaved {
completion?(tokens.idToken, expirationDate)
} else {
AppManager.updateTokenInDb(token: tokens.idToken, accessTokenExpirationDate: expirationDate)
completion?(tokens.idToken, expirationDate)
}
}
else{
completion?(nil, nil)
}
}`
Successfully completed execution for Auth.fetchSessionAPI with result: { awsCredentialsError = "AuthError: Could not fetch AWS Credentials, AWS Cognito Identity Pool is not configured\nRecovery suggestion: Follow the steps to configure AWS Cognito Identity Pool and try again\nCaused by:\ninvalidAccountTypeException"; cognitoTokens = "[\"accessToken\": \"ey*****Og\", \"refreshToken\": \"ey*****UA\", \"idToken\": \"ey*****lg\", \"expiry\": 2024-07-19 05:57:33 +0000]"; identityIdError = "AuthError: Could not fetch identity Id, AWS Cognito Identity Pool is not configured\nRecovery suggestion: Follow the steps to configure AWS Cognito Identity Pool and try again\nCaused by:\ninvalidAccountTypeException"; isSignedIn = true; userSub = "2ed9e*****b75e8"; }
Well from the logs I can see that the tokens have values which seem to be correct..
cognitoTokens = "[\"accessToken\": \"ey*****Og\", \"refreshToken\": \"ey*****UA\", \"idToken\": \"ey*****lg\", \"expiry\": 2024-07-19 05:57:33 +0000]";
Furthermore, the error that you see is related to Cognito Identity, which is expected, since you don't have identity pool configured.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
Once user is logged in and after the token expires, it is not getting refreshed. It was working a week before.
Steps To Reproduce
Expected behavior
New token should get generated and await should respond.
Amplify Framework Version
2.35.7
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
5.0
CLI version
12.12.4
Xcode version
Xcode 15.0 Build version 15A240d
Relevant log output