I keep receiving a token expire message when trying to login with flutter.
I set up secure login. I receive a token from my server. Then I do the following:
final token = await AmityUserTokenManager(
endpoint: AmityRegionalHttpEndpoint.US,
apiKey: SocialJawn.amityApiKey,
).createUserToken(
user.id,
displayname: user.socialInfo!.username,
secureToken: data.data,
);
final u = await AmityCoreClient.login(user.id)
.displayName(user.socialInfo!.username)
.authToken(token.accessToken)
.submit();
Yet I always either receive a token expire message or Parameters validation error! error for the login function as an exception.
I am using amity_sdk: ^0.21.0
The current usage of secured mode is incorrect. The method createUserToken is intended for obtaining a user access token, not an authentication token.
To obtain an authentication token, follow these steps:
Your front-end (FE) should make a call to retrieve the authentication token.
On the back-end (BE) side, invoke the authentication API (Amity API ) using the userId obtained in step 1 and the securely stored serverKey on the BE side.
Pass the token received from the authentication API back to the front-end.
@SocialPlus_Support thanks.
Also it would be nice if the Flutter amity package sdk dependences were updated as with the latest Flutter stable release we can no longer run the application. Mainly the Dio package.
Thank you for bringing this to my attention. I have some good news to share – we are actively working on updating the library in our upcoming version, which we are aiming to deploy in the next release
After the team investigated the token issue, they confirmed that it is functioning as expected. However, it is important to ensure that the auth token is provided.
Yes when I provide the auth token I generated it would receive an error that the token has expired. If I turned off secured mode and didn’t use the authToken I was logged right in.