mirror of
https://github.com/hanzokms/python-sdk.git
synced 2026-10-30 20:30:11 +00:00
- Rename package: infisical_sdk -> hanzo_kms (pip: hanzokms) - Rename classes: InfisicalSDKClient -> KMSClient, InfisicalRequests -> KMSRequests, InfisicalError -> KMSError - Default API host: https://kms.hanzo.ai - Update all imports, docstrings, and user-facing strings - Copyright: Hanzo AI Inc. - Backward-compatible aliases: InfisicalSDKClient, InfisicalError - Env var: INFISICAL_AWS_IAM_AUTH_IDENTITY_ID -> HANZO_KMS_AWS_IAM_AUTH_IDENTITY_ID - Remove obsolete OpenAPI generator files (.travis.yml, .gitlab-ci.yml, etc.)
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
from hanzo_kms.api_types import MachineIdentityLoginResponse
|
|
|
|
from typing import Callable
|
|
from hanzo_kms.kms_requests import KMSRequests
|
|
class UniversalAuth:
|
|
def __init__(self, requests: KMSRequests, setToken: Callable[[str], None]):
|
|
self.requests = requests
|
|
self.setToken = setToken
|
|
|
|
def login(self, client_id: str, client_secret: str) -> MachineIdentityLoginResponse:
|
|
"""
|
|
Login with Universal Auth.
|
|
|
|
Args:
|
|
client_id (str): Your Machine Identity Client ID.
|
|
client_secret (str): Your Machine Identity Client Secret.
|
|
|
|
Returns:
|
|
Dict: A dictionary containing the access token and related information.
|
|
"""
|
|
|
|
requestBody = {
|
|
"clientId": client_id,
|
|
"clientSecret": client_secret
|
|
}
|
|
|
|
result = self.requests.post(
|
|
path="/api/v1/auth/universal-auth/login",
|
|
json=requestBody,
|
|
model=MachineIdentityLoginResponse
|
|
)
|
|
|
|
self.setToken(result.data.accessToken)
|
|
|
|
return result.data
|