hey! i have a question about oauth2. i basically u...
# ktor
b
hey! i have a question about oauth2. i basically used the code here https://ktor.io/servers/features/authentication/oauth.html . what happens when i pass a invalid scope (just an example) i basically create an endless loop. the callback tries to send an error reponse back to the /oauth endpoint, the endpoint sees "not authenticated" redirects back to my oauth provider it tries to send the error response .. any ideas how to fix it?
ah ok easy .. i just had to move the error handling route out of authenticate {}
`
Copy code
location<login> {
            param("error") {
                handle {
                    call.loginFailedPage(call.parameters.getAll("error").orEmpty())
                }
            }
}
authenticate("gitHubOAuth") {
        location<login>() {
        
            handle {
                val principal = call.authentication.principal<OAuthAccessTokenResponse>()
                if (principal != null) {
                    call.loggedInSuccessResponse(principal)
                } else {
                    call.loginPage()
                }
            }
        }
    }