Middleware
Create Middleware
Version | 1.4.0 |
---|---|
Owner | PT Verihubs Inteligensia Nusantara |
Release Date | 2 September 2024 |
Approved By | Edwin Layani, Gisela Swastika |
Overview
Verihubs SDK makes verification easy. Find the documentation and sample code you need to build what you
want exactly. We will handle the global regulations.
Technical Design
The main purpose to build SDK Proxy is to isolate the credentials information from the client and combine it
with your own business needs.
Getting Started
Choose your programming language and dive in. We have got Quickstarts to get you integrate with our
Liveness service in your app.
For forwarding the response, please do not change the response value from Verihubs Liveness
Service. Additional json field might be added, so please ignore them while checking the
existing fields.
Python
# Import the required libraries, we are using fastapi for this example
import os
import requests
from fastapi import FastAPI
from fastapi.responses import Response
from fastapi import Request
# Find your Application ID and API Key at <https://app.verihubs.com>
# and set as the Environment variables.
VERIHUBS_APP_ID = os.getenv("VERIHUBS_APP_ID")
VERIHUBS_API_KEY = os.getenv("VERIHUBS_API_KEY")
# Create the POST Request for integrating with Verihubs Service.
# Forward exactly the response from the Verihubs Service to avoid invalid
schema exception.
app = FastAPI()
@app.post("/liveness")
async def liveness(
request: Request
):
response = requests.post(
"<https://api.verihubs.com/v1/face/liveness>",
headers={
"App-ID": VERIHUBS_APP_ID,
"Api-Key": VERIHUBS_API_KEY,
},
json=await request.json(),
)
return Response(
status_code=response.status_code,
headers=dict(response.headers),
content=response.content,
)
@app.post("/{license_id}/check")
async def license(
license_id: str,
request: Request,
):
response = requests.post(
"<https://api.verihubs.com/v1/license/{license_id}/check>".format(license_id=license_id),
headers={
"App-ID": VERIHUBS_APP_ID,
"Api-Key": VERIHUBS_API_KEY,
},
json=await request.json(),
)
return Response(
status_code=response.status_code,
headers=dict(response.headers),
content=response.content,
)
@app.post("/generate-key")
async def generate_key(
request: Request
):
response = requests.post(
"<https://api.verihubs.com/v1/encryption/generate-key>",
headers={
"App-ID": VERIHUBS_APP_ID,
"Api-Key": VERIHUBS_API_KEY,
},
json=await request.json(),
)
return Response(
status_code=response.status_code,
headers=dict(response.headers),
content=response.content,
)
Updated 4 months ago