Only one token per request is possible so use `header` instead of `addHeader`

This commit is contained in:
Benoit Marty 2020-08-03 15:06:15 +02:00 committed by Benoit Marty
parent 4cbb2f7d9d
commit 8cc12fb8d4
1 changed files with 3 additions and 3 deletions

View File

@ -25,10 +25,10 @@ internal class AccessTokenInterceptor(private val accessTokenProvider: AccessTok
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()
accessTokenProvider.getToken()?.let {
// Add the access token to all requests if it is set
accessTokenProvider.getToken()?.let { token ->
val newRequestBuilder = request.newBuilder()
// Add the access token to all requests if it is set
newRequestBuilder.addHeader(HttpHeaders.Authorization, "Bearer $it")
newRequestBuilder.header(HttpHeaders.Authorization, "Bearer $token")
request = newRequestBuilder.build()
}