flask-dance
flask-dance copied to clipboard
Simplify oauth_authorized with redirect
repost from https://github.com/singingwolfboy/flask-dance/issues/203#issuecomment-486333141 (CC @daenney @singingwolfboy)
Right now the expectation is that writers of oauth_authorized
callbacks handle saving the token if they want a redirect. This leads to more complicated logic to handle redirects (see linked comment), reposted here:
why push that responsibility on the user? Seems like there is a non trivial amount of logic in setting the token (ie handling errors) that I would guess most consumers would still want to use.
I think in the base case of just wanting to customize redirects (ie to send the user back to the where they originally came from) where the logic is:
next_url = flask.session["next_url"]
return flask.redirect(next_url)
having to also set the token seems unnatural.
I suggest improving the DX here to allow returning the a response and still re-using the existing set token logic.