Skip to content

Conversation

@shaneikennedy
Copy link

Summary

Changes

#109

It's recommended in the docs and afaik as good practice to preserve some sort of state during an auth flow like this. Currently with this library there's no way to send in state during the authorization that I can get back on redirect and verify.

Results

My changes only include an update to enable stateful redirect on the ImplicitGrantStrategy and I believe I've done it in a non-breaking way with an optional string argument

When a client using the ImplicitGrantStrategy calls authorize on the main SpotifyApi object, they can now provide a state string as an argument that they can expect to see on the redirectUri after a successful authentication

I've opened this as a draft PR only for the ImplicitGrantStrategy for the time being to see if this is something that's even wanted by others using this library. If the maintainers like the feature then I'd be happy to expand on this PR or provide follow up PRs to implement stateful redirect for other applicable flows.

refresh_token: hashParams.get("refresh_token") ?? "",
expires: Number(hashParams.get("expires")) || 0
expires: Number(hashParams.get("expires")) || 0,
state,
Copy link
Author

@shaneikennedy shaneikennedy Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Not sure if I should use the state that's passed in as an arg here or use the query params like the other fields are using.... suggestions very welcome

@shaneikennedy shaneikennedy changed the title feat: stateful redirect for implicitgrantstrategy Stateful redirect for implicitgrantstrategy Mar 26, 2024
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

Successfully merging this pull request may close these issues.

1 participant