Closed reivilibre closed 3 years ago
i think that managing knowing when to refresh is really a slightly higher-level concern than where this library sits.
I have another project with an 'auto-refreshing' client, perhaps i can add that as an example of how this can work
see https://github.com/danieleades/monzo-lib/pull/27
essentially you can check the error variant to infer that auth has expired. Or, if you want to track the expiry time in some higher-level wrapping struct, I'd be happy to look at a pull request to expose expiry time field?
I've merged the example. Will close this issue. Feel free to reopen if this doesn't solve your problem, or you have more questions
@reivilibre i've updated the 'refresh' endpoint to return the number of seconds until expiry - #28
The endpoint that acquires access tokens returns an expiry time, but the
refresh_auth
function doesn't expose that and I don't know how you'd know when to refresh — it doesn't look like it happens automatically, for example.I guess one could detect requests failing with authorisation issues, but that seems like it would be a bit messy?