[Rest] OAuth2 bearer tokens and refresh of tokens #3165
Labels
pkg-rest
Affects the rest package
w-pending
This depends on a different Issue/PR being resolved
w-verified
This had been verified
Milestone
Describe the bug:
Given a Bearer token got after a code exchange with discord the token gets used to do requests and discordeno creates queues mapped in the restManager.queues with the following key:
Bearer <token here>/<url here>
1. The problem is when the access token gets refreshed (even if it's before it expires) the token changes but the ratelimit is still the same, also the old queue that was created might still have pending request to send but since refreshing a token implies invaliding the old one the pending requests will fail with a401 & Unauthorized
error and if a new request gets sent before the ratelimit for an endpoint is refreshed2 it will fail with a429 & Too many requests
To Reproduce:
Expected behavior:
There shouldn't be an Invalid request performed for
429 & Too many requests
Screenshots:
The censored lines in the log are an input for the code to exchange
Version details:
Discordeno version: v19 dev, commit eec292728571d60bfe04c87260279d969a328be2
Footnotes
The / is in fact part of the url, it is explicit in to separate the token and url ↩
For example: a token is used to do a request on
/users/@me/guilds
and then the token refreshes and another request is sent to that same url it will fail ↩The text was updated successfully, but these errors were encountered: