auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
57 stars 36 forks source link

Allow accessing credentials without an attempt to refresh #378

Open MilesAdamson opened 7 months ago

MilesAdamson commented 7 months ago

Checklist

Describe the problem you'd like to have solved

For apps which are designed around the user being offline frequently, the following flow would be great:

Currently, this is harder to achieve because credentials of DefaultCredentialsManager will always try to refresh the token, which fails without internet. Since this is the only method which access credentials, there is no way to just get the cached (expired) credentials. This would be convenient to have so that in the offline state, we can still restore the users id/roles/permissions as to what they should be able to view in that offline state.

Describe the ideal solution

Add a method to CredentialsManager to get the cached credentials, without any attempt to refresh them. Or, add a boolean to the input of CredentialsManager.credentials to do the same behavior.

Alternatives and current workarounds

Alternatively it would be possible to cache the users id/roles/permissions ourselves to use in the app during the offline state. But this would be redundant with the credentials already in the manager, if we could access them.

It would also be possible to write our own implementation of credentials manager, to returns expired credentials from credentials if it fails to refresh while offline. But it defeats the purpose of the default manager to need to re-write the api calls to refresh the tokens and such

Additional context

No response