ring-oauth2 icon indicating copy to clipboard operation
ring-oauth2 copied to clipboard

Allow supplying custom success, error handlers

Open kaosko opened this issue 8 years ago • 5 comments

Currently, redirect handler forces redirecting to the landing-uri on success but I often like to do something with the newly gained access token right away, like fetch user details, (open) id, federating with local user account etc. Would you consider supporting optional custom handlers for each profile, e.g. {:success-handler (fn [access-token] ...)}?

kaosko avatar Nov 18 '17 05:11 kaosko

I assume you know that you can just put the success handler on the landing-uri, and that you're suggesting an optimisation?

weavejester avatar Nov 19 '17 13:11 weavejester

Well a bit more than on optimization I guess. It's still going to do a redirect and expects a potential function to return a landing-uri. And on error, it just returns 400.

kaosko avatar Nov 19 '17 17:11 kaosko

Sure, but you could do all of those things from the landing-uri. The only thing a success handler gives you, as far as I can see, is that you get to perform actions before the redirect.

weavejester avatar Nov 19 '17 17:11 weavejester

Or even without a redirect. But yes, of course.

kaosko avatar Nov 19 '17 17:11 kaosko

https://github.com/weavejester/ring-oauth2/pull/37 partially addresses this issue, but the limitation is that :redirect-handler replaces the default handler when present. I would have thought it made more sense to always apply the default handler and then pass a success / error result to :redirect-handler when it is present. That's because we're always going to need to execute get-access-token.

whamtet avatar Mar 07 '23 20:03 whamtet