Skip to content

Instantly share code, notes, and snippets.

@simonr-cb
Created January 12, 2018 16:33
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 simonr-cb/2c9a545794ba96b2318648878d47c19e to your computer and use it in GitHub Desktop.
Save simonr-cb/2c9a545794ba96b2318648878d47c19e to your computer and use it in GitHub Desktop.
/**
* 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