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

Scope not being passed to refreshToken() in fetch wrapper #138

Open
spencerldixon opened this issue Feb 28, 2024 · 1 comment
Open

Scope not being passed to refreshToken() in fetch wrapper #138

spencerldixon opened this issue Feb 28, 2024 · 1 comment

Comments

@spencerldixon
Copy link

I'm not a big js guy so please forgive me if I'm doing a fridge temperature IQ move here but...

I'm using the fetch wrapper to send POST requests from a chrome extension to an app. I can oauth between the two successfully, but when a refreshToken happens from the fetch wrapper, my backend returns a 400 bad request.

Looking into this, I noticed the difference between the two requests is that the refresh requests are missing the scope.

I saw this PR which adds an optional scope param to refreshToken (https://github.com/badgateway/oauth2-client/pull/135/files) but it doesn't look like it's been added to the fetch wrapper https://github.com/badgateway/oauth2-client/blob/main/src/fetch-wrapper.ts#L157

Am i missing something? Is there a way to ensure the scope from the client makes it through to refresh requests in the fetch wrapper?

@evert
Copy link
Collaborator

evert commented Mar 2, 2024

Hey, the fetch wrapper doesn't do anything with this currently. The scope should be inherited from the original access token:

scope
OPTIONAL. The scope of the access request as described by
Section 3.3. The requested scope MUST NOT include any scope
not originally granted by the resource owner, and if omitted is
treated as equal to the scope originally granted by the
resource owner.

https://datatracker.ietf.org/doc/html/rfc6749#section-6

Are you using a server that doesn't respect this, or are you trying to use the scope parameter to change the scope from what it originally was?

if it's the former I would suggest you try to file a bug report with your vendor. Bug fixes are better than workarounds for sloppy implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants