HTTP Request Customization in Android
For Android, you can specify the NetworkInterceptorListener
listener which provides you with a callback that receives HttpRequestBuilder
right before they are fired.
If you want to intercept HTTP requests, make sure to specify the listener before startLiveness
or matchFaces
:
private val authorization = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmYWNlLXNkayI6IkhhdmUgYSBncmVhdCBkYXkhIn0.IPoW0D0LnMv_pL4U22MuIhDNGIdK34TaHhqhKBAaBEs"
private val networkInterceptorListener: NetworkInterceptorListener =
NetworkInterceptorListener() { httpRequestBuilder: HttpRequestBuilder ->
HttpRequestBuilder.connection.setRequestProperty("Authorization", authorization)
}
FaceSDK.Instance().setNetworkInterceptorListener(networkInterceptorListener)
Face.Instance().startLiveness(this@MainActivity) { livenessResponse: LivenessResponse? -> }
private String authorization = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmYWNlLXNkayI6IkhhdmUgYSBncmVhdCBkYXkhIn0.IPoW0D0LnMv_pL4U22MuIhDNGIdK34TaHhqhKBAaBEs";
private NetworkInterceptorListener networkInterceptorListener = new NetworkInterceptorListener() {
@Override
public void onPrepareRequest(HttpRequestBuilder httpRequestBuilder) {
httpRequestBuilder.getConnection().setRequestProperty("Authorization", authorization);
}
};
FaceSDK.Instance().setNetworkInterceptorListener(networkInterceptorListener);
Face.Instance().startLiveness(MainActivity.this, livenessResponse -> {});