Hey folks, new to Ktor, so sorry in advance if thi...
# ktor
j
Hey folks, new to Ktor, so sorry in advance if this has been asked before. We don't use basic, digest, or bearer scheme for auth. Just a simple "Authorization:AuthToken" pattern, so I don't believe I can use the Ktor Auth plugin. I need to attach an "Authorization" header to some of my requests. How can I conditionally apply the header so that it's only attached when needed? I thought to use the HttpSend plugin, but thats basically an interceptor that intercepts every request iiuc.
a
You can write your own authentication provider by implementing the
AuthProvider
interface to use the
Auth
plugin or you can manually add the
Authorization
header for each request.
j
Got it - happen to have an example for implementing
AuthProvider
approach?
a
Please take a look into the implementation of the BasicAuthProvider.
j
Will do, thanks @Aleksei Tirman [JB]!