-
Notifications
You must be signed in to change notification settings - Fork 60
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
Automatically call authorize_account on 401 #56
Comments
Seems like a good idea, but that may be a bit tricky to embed it, because it can happen for any call. So we would essentially have do |
You just need to check a timestamp before every call. Every time you call authorize() you save a timestamp 24hours ahead which will be checked. |
+1. |
Note that we should handle the case where multiple requests are made in the same tick. We don't want each one generating a new const reauth = memoize(
() => client.authorize(),
{ promise: true, maxAge: 1000 * 60 * 10 /* 10 minutes */ }
); |
Perhaps we should have
backblaze-b2
automatically callauthorize_account
when it encounters a 401 error, or have it as an option at least.I encountered an issue in a long-running application where after 24 hours all calls stopped working.
https://www.backblaze.com/b2/docs/application_keys.html
It would be nice if the module automatically did this rather than the user having to: 1. Call
authorize
before every method (incurs a Class C transaction cost), 2. Add an error handler to every call to check for 401s, or 3. Add asetInterval
every 24 hours to authorize (a bit hacky).Thoughts?
The text was updated successfully, but these errors were encountered: