Some attempts to refresh OAuth tokens on the farmOS server are failing, but only when there are two back-to-back attempts to refresh using the same refresh_token.
It's unclear how often this happens, but some of the time the second request fails (as expected) because the refresh_token has already been used. Other times both requests succeed, which shouldn't happen. This is likely due to how the farmOS server (and underlying oauth2_server module) handle the request to refresh tokens.
The larger issue, though, is that there are two attempts to refresh tokens. One thought is that when instantiating farmOS.py it makes multiple requests to the server (to get a CSRF token) and later process the request (and both of these might try to refresh a token before hand) but these are handled synchronously so I don't believe this is causing the problem.
I think it's likely that if multiple requests come to the aggregator requesting data from the same farmOS server, after an access token has expired (every hour under sustained use), then there could sometimes be multiple attempts to refresh the same token.
Some attempts to refresh OAuth tokens on the farmOS server are failing, but only when there are two back-to-back attempts to refresh using the same
refresh_token.It's unclear how often this happens, but some of the time the second request fails (as expected) because the
refresh_tokenhas already been used. Other times both requests succeed, which shouldn't happen. This is likely due to how the farmOS server (and underlyingoauth2_servermodule) handle the request to refresh tokens.The larger issue, though, is that there are two attempts to refresh tokens. One thought is that when instantiating farmOS.py it makes multiple requests to the server (to get a CSRF token) and later process the request (and both of these might try to refresh a token before hand) but these are handled synchronously so I don't believe this is causing the problem.
I think it's likely that if multiple requests come to the aggregator requesting data from the same farmOS server, after an access token has expired (every hour under sustained use), then there could sometimes be multiple attempts to refresh the same token.