Created
January 12, 2018 16:33
-
-
Save simonr-cb/2c9a545794ba96b2318648878d47c19e to your computer and use it in GitHub Desktop.
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
/** | |
* Intercept the given request chain to add the Approov token to an 'Approov-Token' header. | |
* | |
* @param chain the request chain to modify | |
* @return the modified response, authenticated by Approov | |
*/ | |
override fun intercept(chain: Interceptor.Chain): Response { | |
val originalRequest = chain.request() | |
val approovToken = ApproovAttestation.shared().fetchApproovTokenAndWait(originalRequest.url().toString()).token | |
val approovRequest = originalRequest.newBuilder().addHeader("Approov-Token", approovToken).build() | |
return chain.proceed(approovRequest) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment