Skip to content

HTTP Request Customization in Android

For the Android platform, you can specify the NetworkInterceptorListener listener which provides you with a callback that receives HttpURLConnection right before they are fired.

You can specify a listener at any time, except the matchFaces request. When you call the matchFaces method and want to intercept HTTP requests, you have to specify NetworkInterceptorListener first:

FaceSDK.Instance().setNetworkInterceptorListener {
    it.setRequestProperty("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmYWNlLXNkayI6IkhhdmUgYSBncmVhdCBkYXkhIn0.IPoW0D0LnMv_pL4U22MuIhDNGIdK34TaHhqhKBAaBEs")
}
Face.Instance().startLiveness(this@MainActivity) { livenessResponse: LivenessResponse? -> }
FaceSDK.Instance().setNetworkInterceptorListener(httpURLConnection -> {
    httpURLConnection.setRequestProperty("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmYWNlLXNkayI6IkhhdmUgYSBncmVhdCBkYXkhIn0.IPoW0D0LnMv_pL4U22MuIhDNGIdK34TaHhqhKBAaBEs");
});
Face.Instance().startLiveness(MainActivity.this, livenessResponse -> {});
Back to top