You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing an app in Flutter and I've noticed that my beta users have to log in every 1 hour or less, which is not ideal. I use Logto and Mongodb authenticating the users by JWT.
To make the session more persistent I created a function that checks if the user is authenticated, first I request the access token and then the idToken, if the idToken is not null then it authenticates the user silently but if it is null then it returns the user to the login screen.
await logtoClient.getAccessToken(); // To refresh the access token
final String? idtoken = await logtoClient.idToken; // Used to authenticate user in realm (mongodb) by JWT
print(await logtoClient.isAuthenticated); // true
When I print this it returns the access token and the idToken but immediately I run getUserInfo() it gives me an error.
LogtoUserInfoResponse user = await logtoClient.getUserInfo();
Run the function getUserInfo() to return the user info that is necessary for the app functionality.
You should not get this error if the access token is refreshed and valid and also if the “isAuthenticated” method returns true.
According to the code of the function getUserInfo(), it throws this error when the access token is null, which does not make sense if before executing this function it returns me the valid and refreshed access token, and also returns me the idToken.
How to reproduce?
(Only tested on Android)
Wait for the access token to expire after authenticating the user.
Open the app and run the function that checks if the user is authenticated.
Run await logtoClient.getAccessToken();
Get the idToken final String? idtoken = await logtoClient.idToken;
Get the user info await logtoClient.getUserInfo();
Context
logto_dart_sdk: ^1.2.0
Screenshots
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm developing an app in Flutter and I've noticed that my beta users have to log in every 1 hour or less, which is not ideal. I use Logto and Mongodb authenticating the users by JWT.
To make the session more persistent I created a function that checks if the user is authenticated, first I request the access token and then the idToken, if the idToken is not null then it authenticates the user silently but if it is null then it returns the user to the login screen.
When I print this it returns the access token and the idToken but immediately I run getUserInfo() it gives me an error.
LogtoUserInfoResponse user = await logtoClient.getUserInfo();
Error:
Expected behavior
Run the function
getUserInfo()
to return the user info that is necessary for the app functionality.You should not get this error if the access token is refreshed and valid and also if the “isAuthenticated” method returns true.
According to the code of the function getUserInfo(), it throws this error when the access token is null, which does not make sense if before executing this function it returns me the valid and refreshed access token, and also returns me the idToken.
How to reproduce?
(Only tested on Android)
await logtoClient.getAccessToken();
final String? idtoken = await logtoClient.idToken;
await logtoClient.getUserInfo();
Context
Screenshots
The text was updated successfully, but these errors were encountered: