Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This turns out to be the core of the issue/misunderstanding that we have been seeing.
When we modified the value for expiry to 0 it didn't really take effect.
The token that was sent back in response to HQ, is the one that was passed to the function
save_token
and is expected to be stored as it is, though we were modifying it here which would lead to a mismatch in what HQ was told about the token and what we stored. So, a token even if valid according to HQ could be expired as per CommCareAnalytics or vice versa.This didn't cause any mismatch back then because it set the default value of 1 day which was also the value set for expiry for the token. And HQ was requesting a new token for every request anyway.
But then we modified it to 0 or 10 which was different from what HQ had for the token.
So, when HQ was updated to reuse token here, it would get a 401 instead when we modified the value for token expiry to anything other than 1 day, and it was set to 10 seconds recently.
I have added an example of how to correctly override the expiry time.
We can consider adding back revoking tokens, 4c73ffd