fallback

Specifies a fallback function invoked when OAuth flow fails with an AuthenticationFailedCause.Error, e.g., a token exchange error, network/parse failure, or invalid_grant error.

If invalid_grant occurs, this fallback is invoked. If the fallback handles the call (e.g., by responding), Ktor completes the authentication flow. If the fallback does not handle the call, Ktor falls back to the redirect challenge to try to automatically recover the authentication flow.

For other errors, or if the fallback handles the call, Ktor will not execute the redirect challenge and will respond with 401 Unauthorized if the call remains unhandled by the fallback.

Report a problem