diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt index a15f660790..4646cb2fca 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/AccessTokenInterceptor.kt @@ -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() }