Skip to content
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

fix(RequestHandler): only reset tokens for authenticated 401s #7508

Merged

Conversation

vladfrangu
Copy link
Member

Please describe the changes this PR makes and why it should be merged:

Closes #7492 by resetting the token only when an authorized request fails with a 401.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@ckohen
Copy link
Member

ckohen commented Feb 20, 2022

Instead of passing around an extra property everywhere, can you not just check for the Authorization Header?

I know a user can technically override it when passing auth: false, but that's not supported

@vladfrangu
Copy link
Member Author

vladfrangu commented Feb 20, 2022

We'd have to normalize the headers to always be lowercased no matter if we or users provided it I suppose... Bit of a pitfall of how we pass data down from the manager to the handler

@ckohen
Copy link
Member

ckohen commented Feb 20, 2022

What do you mean by that? the header is passed as Authorization, not authorization

packages/rest/src/lib/RequestManager.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/handlers/SequentialHandler.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/RequestManager.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/RequestManager.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/RequestManager.ts Outdated Show resolved Hide resolved
@iCrawl iCrawl added this to the rest v1 milestone Feb 20, 2022
packages/rest/src/lib/REST.ts Outdated Show resolved Hide resolved
@vladfrangu vladfrangu requested a review from kyranet March 6, 2022 15:41
@iCrawl iCrawl merged commit b9ff7b0 into main Mar 6, 2022
@iCrawl iCrawl deleted the fix/rest/reset-token-on-401-only-for-authenticated-calls branch March 6, 2022 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

rest clears token on 401s
6 participants