Languages
Python
Learn more about using Oneloop Python SDK
Installation
bash
pip3 install oneloop-python
Authentication
from oneloop_client.client import OneloopApi
# Initialize the SDK client
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 the API key
verify_response: VerifyApiKeyResponse = None
try:
verify_response = oneloop_client.verify_api_key(
key="<API_KEY>", # The Api Key that was generated for the user (either through the SDK or dashboard)
requested_scopes=[
{
"id": "balance_transfer", # The requested scope
"representation": "balance_transfer",
"read": False,
"create": True, # Allow creation
"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)