The SDK can be integrated into a gRPC project.
Application’s onCreate function on Android.AppDelegate’s didFinishLaunchingWithOptions function on iOS.Here is an example of how it should be:
Kotlin:
Swift:
Let’s talk about what we have in the code here:
HSPolicy instance. This object is used to configure the SDK’s behavior. Here, we set the HSAutomaticInterceptorPolicy/interceptorType property to HSAutomaticInterceptorType/none. This means that the Automatic Interception feature of the SDK is disabled. In short, this feature allows the SDK to manipulate URL requests and handle their responses by itself. However, this feature is not supported in gRPC.HumanSecurity/start(appId:policy:) function of the SDK. We provide the following parameters:
Application instance (Android only).Note: If your app communicates with several servers that have different AppID, you can call the HumanSecurity/start(appIds:policy:) function which allow you to pass an array of AppIDs. You should specify the relevant AppID for each API call in the SDK.
Here is an example of how it should be:
Kotlin:
Kotlin
The HUMAN’s Enforcer, when it decides to block a request, returns a JSON string in the response’s body. The HTTP status code is 403. Here is an example of the response:
The JSON contains metadata for the SDK.
Your app should pass the whole JSON to the SDK via the HSBotDefender/handleResponse(response:data:callback:) function. Otherwise, the SDK won’t present a challenge to the user.