Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token expiration problem #22

Open
armanhadifatah opened this issue Apr 24, 2024 · 4 comments
Open

Token expiration problem #22

armanhadifatah opened this issue Apr 24, 2024 · 4 comments

Comments

@armanhadifatah
Copy link

I created authentication like this

  DirectusApiManager directusApiManager = DirectusApiManager(
      baseURL: "https://control.seedkurdistan.org",
      saveRefreshTokenCallback: (refreshToken) async {
// Create storage
        var storage = ref.read(flutterSecureStorageProvider);
        await storage.write(key: refreshStorage, value: refreshToken);
      },
      loadRefreshTokenCallback: () async {
        var storage = ref.read(flutterSecureStorageProvider);
        var token = await storage.read(key: refreshStorage);
        // now if token is expired, we can load it from storage
        return token;
      });

but still when the token expire it will not automatically use the new one the app crash but if i close and open the app work again

@maxbritto
Copy link
Owner

maxbritto commented Apr 26, 2024

Hello @armanhadifatah !
Could you provide more information about the crash your are mentioning ?

@armanhadifatah
Copy link
Author

Hello @armanhadifatah ! Could you provide more information about the crash your are mentioning ?

After a while I get error that token expired , but with a refresh its again ok and no error

@maxbritto
Copy link
Owner

My guess is that you might have an issue with your saving/loading of the token.
Maybe this doesn't work as expected since I do not know this dependency : ref.read(flutterSecureStorageProvider);

I would love to help more but you need to provide more details : the exact error displayed with stack trace would be a good start :)

@armanhadifatah
Copy link
Author

My guess is that you might have an issue with your saving/loading of the token. Maybe this doesn't work as expected since I do not know this dependency : ref.read(flutterSecureStorageProvider);

I would love to help more but you need to provide more details : the exact error displayed with stack trace would be a good start :)

Thanks for your reply could you please give me the best way how to do it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants