Why may Ktor Authentication feature's authenticate...
# ktor
m
Why may Ktor Authentication feature's authenticated route handlers be executed with empty principal, despite of not being optional? Code further in thread
Copy code
routing {
    authenticate("vk") {
        location<login>(){
              //... endpoint i use for communication with oAuth2 service
        }
        get("locked"){
            val principal = call.authentication.principal<OAuthAccessTokenResponse.OAuth2>() //principal is null, why?
            call.respondText {
                "Oh hi mark!"
            }
        }
    }
}
There is an issue in multiple samples in github of Ktor, that is being fixed, by, as I think, a hack with session == null -> redirect in every endpoint, because OAuthProvider with providerLookup returning null is just being ignored.
s
I'm also experiencing this behaviour, what approach did you take to solve it afterall? Does it happen to be as part of an open sourced project I can take a look at?