When we want to use Ktor Client to access endpoint...
# ktor
d
When we want to use Ktor Client to access endpoints with or without authentication; is it expected we'll keep both 'authenticated' and 'unauthenticated'
HttpClient
instances on hand, and pick one? Or, is there a lighter way to opt to use the installed authentication, or not, per call?
not sure if you’re able to override that method
a
@darkmoon_uk unfortunately, no.
d
Thanks. I've currently settled for having both an 'authenticated' client and an 'unauthenticated' client. The thing that tipped me further towards that was; if you want to 'log out' there's no way to clear the keys loaded into JWT authentication, the only way to effectively and reliably drop them seems to be switching client. Ended up injecting a 'provideClient' lambda to my services which gives either the authenticated or unauthenticated client depending on the session state (login/out). No idea if this is idiomatic but it works for me.