Intercept initial Ktor authenticate route

Solution 1:

Unfortunately, it's not possible to disable a redirect to authorizeUrl using the OAuthAuthenticationProvider. You can add an interceptor for the authenticate route to inject your code just before authentication (redirect) happens.

authenticate("auth-oauth-github") {
    val phase = PipelinePhase("MyPhase")
    insertPhaseBefore(Authentication.AuthenticatePhase, phase)
    intercept(phase) {
        // Do your processing here
        // call.request contains data for the initial request
    }

    // ...
}