Closed kmvignesh closed 1 year ago
Hi @kmvignesh - can you share how you are calling fetchAuthSession
? In vNext, when no identity pool is configured, you'll want to pass getAwsCredentials: false
or just not pass that parameter:
final session = await Amplify.Auth.fetchAuthSession() as CognitoAuthSession;
Hi @kmvignesh - can you share how you are calling
fetchAuthSession
? In vNext, when no identity pool is configured, you'll want to passgetAwsCredentials: false
or just not pass that parameter:final session = await Amplify.Auth.fetchAuthSession() as CognitoAuthSession;
Hey @dnys1 We have configured 'CognitoUserPool'. The same working fine in Android and iOS. Only on window we are getting this issue. If it's a configuration issue then how i was getting the token on hot-restart 🤔.
After login we need to get user details by calling another API. For calling that API i need to pass the idToken in the header. To get that token, After login immediately calling getIdToken function.
Future<String> getIdToken() async {
String idToken = '';
try {
AuthSession res = await auth.fetchAuthSession(
options: const CognitoSessionOptions(getAWSCredentials: true));
idToken = (res as CognitoAuthSession).userPoolTokens!.idToken.raw;
} on AuthException catch (e) {
Log.logError('Error in getting Token \n Error Details: $e');
}
return idToken;
}
Thank you for sharing. Can you try replacing this line:
AuthSession res = await auth.fetchAuthSession(
options: const CognitoSessionOptions(getAWSCredentials: true));
with this
AuthSession res = await auth.fetchAuthSession();
and let me know if that fixes the issue?
I tried that. Its working. But its throwing exception when i kill and re-launch the app.
I generated exe file for windows using flutter build windows
. After that i opened the app and logged in. Then i restarted my system and opened the app. That time it's giving exception No identity pool registered for this account
and we are redirecting the user to login page. Now simply i close the app and reopen it. Now it's giving the token.
So you are still receiving the exception No identity pool registered for this account
after making this change? Are you calling fetchAuthSession
anywhere else?
When no identity pool is configured, passing getAWSCredentials: true
to fetchAuthSession
will result in this exception being thrown. This is different than the behavior on 0.x
versions of Amplify. Please confirm you have removed all instances of getAWSCredentials: true
and are still receiving the exception.
@kmvignesh - Can you confirm that there are no other locations where fetchAuthSession
is called with getAWSCredentials: true
?
@kmvignesh - If you are still facing this issue, can you please provide the info requested above? Thanks.
Hi @kmvignesh sorry we didn't hear back from you. Please feel free to reopen and follow up if you need further assistance.
Description
using following dependencies
Using below function user is able to login.
After login we are getting the token by calling
fetchAuthSession
function. While calling this getting following exceptionInvalidAccountTypeException(message: No identity pool registered for this account, recoverySuggestion: Register an identity pool using the CLI or set getAWSCredentials to false, underlyingException: null)
I tried hot restart. After hot restart, 2 times the function giving correct token, then again started giving same exception. The same code is working fine on Android and iOS
Categories
Steps to Reproduce
Try calling fetchAuthSession multiple times after signin
Screenshots
No response
Platforms
Android Device/Emulator API Level
API 31, API 32+
Environment
Dependencies
Device
MSI
OS
Windows 11 22621.674
Deployment Method
Amplify CLI
CLI Version
No response
Additional Context
No response
Amplify Config