It should be easier to pass along custom state with OAuth2
I'm in need of customising the state parameter that gets passed along to the OAuth2 provider, and I'm finding it incredibly difficult to do so. It would be amazing if the Adapater had a hook for customising the state object before it was added onto the redirect url.
My use case:
We have dynamic environments (staging, local), with dynamic URLs. It's impractical to register all of these URLs as redirect targets within each of the OAuth2 providers we support. To work around this, we have a proxy service that acts as the redirect target.
Site -> OAuthProvider -> Redirect Service -> Site
The Redirect Service pops some state off the URL to determine the final redirect. Adding this state is proving very difficult.
For what it's worth, we configure the state like so:
state = {target_domain}|{state}
Bumping this for @pennersr. Seems valid but i'm not sure if there is an opportunity to directly support his dynamic env use case... or if this has already been addressed.
I also anticipate needing this. Has anyone found a workaround that's less complex than having an entire proxy service?
@jarshwah @norchai A change landed on the main branch facilitating this, see: ce038b7a. The adapter now has a generate_state_param() method that you can override.
Documentation can be found here: https://docs.allauth.org/en/dev/socialaccount/adapter.html#allauth.socialaccount.adapter.DefaultSocialAccountAdapter.generate_state_param