Skip to content

Instantly share code, notes, and snippets.

@Thelouras58
Last active February 5, 2023 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thelouras58/d2f73cf264f05d8912850d986a044f14 to your computer and use it in GitHub Desktop.
Save Thelouras58/d2f73cf264f05d8912850d986a044f14 to your computer and use it in GitHub Desktop.
Android: Basic Auth Interceptor
class BasicAuthInterceptor(username: String, password: String): Interceptor {
private var credentials: String = Credentials.basic(username, password)
override fun intercept(chain: Interceptor.Chain): okhttp3.Response {
var request = chain.request()
request = request.newBuilder().header("Authorization", credentials).build()
return chain.proceed(request)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment