Link to PYPI package
Installation
pip3 install oneloop-python
Authentication
from oneloop_client.client import OneloopApi
oneloop_client = OneloopApi(token="your-oneloop-api-key")
Verify API Keys
When your user calls your endpoints and you need to verify their API Key then you use the following:
from oneloop_client.types import VerifyApiKeyResponse
verify_response: VerifyApiKeyResponse = None
try:
verify_response = oneloop_client.verify_api_key(
key="<API_KEY>",
requested_scopes=[
{
"id": "balance_transfer",
"representation": "balance_transfer",
"read": False,
"create": True,
"update": False,
"del": False
}
])
except Exception as e:
error: ErrorResponse = json.loads(e.body)
code = error['error']['code']
message = error['error']['message']
raise HTTPException(status_code=code, detail=message)
if verify_response and verify_response.status != "VALID":
raise HTTPException(status_code=401, detail=verify_response.status)