https://kotlinlang.org logo
Title
s

Samusev Semën

05/19/2023, 2:20 PM
Hello everyone! I’m trying to setup oauth-based authorization with Discord on my Ktor app following the tutorial: https://ktor.io/docs/oauth.html Everything is working fine except for one case. If user rejects authorization request by pressing cancel (see screenshot), Discord server sends response on my callback endpoint with access_denied query parameter, like this:
/callback?error=access_denied&error_description=...
And since my
/callback
endpoint under
authenticate
block Ktor server behaves incorrectly - essentially it runs authorization flow again (since there is no authenticated OAuth2 proncipal, user redirects back to discord authorization window). Expected behaviour: let me handle this error and show to the user. Any advices how to tackle this problem?