Is it possible for Ktor Sever and Oauth module to ...
# ktor
d
Is it possible for Ktor Sever and Oauth module to use custom states?
s
What do you mean custom state? 🤔
a
You can implement the
NonceManager
interface and pass it to the
nonceManager
property of the
OAuth2ServerSettings
to override the nonce generation which is used for the state:
Copy code
install(Authentication) {
    oauth {
        // ...
        providerLookup = {
            OAuthServerSettings.OAuth2ServerSettings(
                // ...
                nonceManager = object : NonceManager {
                    override suspend fun newNonce(): String {
                        return "my-nonce"
                    }

                    override suspend fun verifyNonce(nonce: String): Boolean {
                        return true
                    }
                },
                // ...
            )
        }
        // ...
    }
}
d
@simon.vergauwen https://ktor.io/docs/server-oauth.html#flow I would like to set state parameter and read it in callback