There are scenarios were we would like to renew the access token regardless of how much time is left on it. Right now the only way to accomplish this via the CredentialsManager is to pass in a minTtl that is greater than the current active token's TTL but less than the TTL of a newly generated token otherwise we will get an error. Right now with the SDK it's very awkward because there is no way to get the token life (unless I've missed something) except by taking the credentials.expiresAt value at time of generation and doing some time math.
Describe the ideal solution
There are a few solutions that could work.
Add a Bool parameter to the credentials call with a default value of false such as forceRefresh or forceRenewal or ignoreCache .
Make it easier to get the access token life by storing it in the credentials object as something like tokenLife to match minTtl parameter we need to pass
Alternatives and current workarounds
As a work around for now we can do as I described in the problem description by calculating the token life of a newly generated token from the credentials.experiesAt and subtracting the current time and passing that into the minTtl parameter of the CredentialsManager.credentials() method.
Another work around would be to use api.renewCredentials call which doesn't require minTtl or any calculations. The problem is this bypasses the local auth/biometrics feature tied to access the credentials via the CredentialsManager.
Checklist
Describe the problem you'd like to have solved
There are scenarios were we would like to renew the access token regardless of how much time is left on it. Right now the only way to accomplish this via the CredentialsManager is to pass in a
minTtl
that is greater than the current active token's TTL but less than the TTL of a newly generated token otherwise we will get an error. Right now with the SDK it's very awkward because there is no way to get the token life (unless I've missed something) except by taking thecredentials.expiresAt
value at time of generation and doing some time math.Describe the ideal solution
There are a few solutions that could work.
forceRefresh
orforceRenewal
orignoreCache
.tokenLife
to matchminTtl
parameter we need to passAlternatives and current workarounds
As a work around for now we can do as I described in the problem description by calculating the token life of a newly generated token from the credentials.experiesAt and subtracting the current time and passing that into the minTtl parameter of the CredentialsManager.credentials() method.
Another work around would be to use api.renewCredentials call which doesn't require minTtl or any calculations. The problem is this bypasses the local auth/biometrics feature tied to access the credentials via the CredentialsManager.
Additional context
Thanks for your consideration!