OAuth2
OAuth2 copied to clipboard
Many 401s
I sometimes have issue were my app continues to call the backend API when getting a 401. Sometimes I end up getting many many 401s from a user in a very short time span.
I am using OAuths OAuth2DataLoader
, but given these many 401s I am wondering if I am using it correctly.
I use it like so:
dataLoader.perform(request: req, retry: true) { response in
...
}
So retry
is set to true
. By reading the docs I understand that that means that if the response is 401, the request is enqueued and then retried when tokens have been refreshed.
So the request will not be retired until the user has been re-authrozied. Is that correctly understodd?
Also, I should mention that for each request I am constructing a new OAuth2DataLoader
instance. And when the app becomes active, many dataloader instances are thus working at the "same time". Is that an issue? Should I use same OAuth2DataLoader
instance across all requests?