Skip to content

Instantly share code, notes, and snippets.

// Verify and decode the Approov token and respond with 403 if the JWT
// could not be decoded, has expired, or has an invalid signature
const checkApproovTokenJWT = jwt({
secret: new Buffer(config.approovTokenSecret, 'base64'),
getToken: function fromApproovTokenHeader(req) {
// Retrieve the Approov token used to authenticate the mobile app from the request header
var approovToken = req.get('Approov-Token')
if (!approovToken) {
console.log('\tApproov token not specified or in the wrong format')
}
OkHttpClient.Builder()
.addInterceptor(ApproovRequestInterceptor())
.build()
/**
* 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