Last active
February 5, 2023 17:37
-
-
Save Thelouras58/d2f73cf264f05d8912850d986a044f14 to your computer and use it in GitHub Desktop.
Android: Basic Auth Interceptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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