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: 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:
And since my
endpoint under
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?