Closed n0061q closed 1 year ago
@n0061q I think you may not understand what you want, from your description, the referrer url is not a part of the oauth flow, it is your application's logic requirements. In this case, you can just save the referrer url in your session:
next_url = request.headers.get("Referer")
if next_url:
session['next_url'] = next_url
return oauth.provider.authorize_redirect(redirect_uri)
Then:
next_url = session.get('next_url', url_for(".index"))
return redirect(next_url)
Is your feature request related to a problem? Please describe. I am using Flask OAuth Client (https://docs.authlib.org/en/latest/client/flask.html#routes-for-authorization) However there seem to be no proper way save user defined data to the state with
authorize_redirect
(and to extract in theauthorize
route before callingauthorize_access_token
). This is crutial for such use cases when client needs to redirect user to the original resourse after successfull authentication (e.g. see this)It can be worked aroud as described below but it is a bit hackish.
Describe the solution you'd like
It would be nice if
authorize_redirect
could accept user defined data to save in the state and some method that could get this custom data from the state later while handling the/authorize
request.Describe alternatives you've considered
Workaround (Flask)
Additional context