๐ goiam-python
September 11, 2025 ยท View on GitHub
Python SDK for Go IAM - A lightweight Identity and Access Management server.
Installation
pip install goiam-python
# or
poetry add goiam-python
# or
pipenv install goiam-python
Usage
Initialize the SDK
from goiam import new_service
service = new_service(
base_url="https://go-iam.example.com",
client_id="your-client-id",
secret="your-secret"
)
Verify Authentication Code
try:
token = service.verify("auth-code")
print(f"Access Token: {token}")
except Exception as error:
print(f"Failed to verify code: {error}")
Fetch Current User Information
try:
user = service.me(token)
print(f"User: {user.name} ({user.email})")
except Exception as error:
print(f"Failed to fetch user information: {error}")
Create a Resource
from goiam import Resource
resource = Resource(
id="resource-id",
name="Resource Name",
description="Resource Description",
key="resource-key",
enabled=True,
project_id="project-id",
created_by="creator",
updated_by="updater"
)
try:
service.create_resource(resource, token)
print("Resource created successfully")
except Exception as error:
print(f"Failed to create resource: {error}")
Delete a Resource
try:
service.delete_resource("resource-id", token)
print("Resource deleted successfully")
except Exception as error:
print(f"Failed to delete resource: {error}")
Classes
The SDK provides the following main classes:
User
class User:
id: str
project_id: str
name: str
email: str
phone: str
enabled: bool
profile_pic: str
expiry: Optional[str]
roles: Dict[str, UserRole]
resources: Dict[str, UserResource]
policies: Dict[str, str]
created_at: Optional[str]
created_by: str
updated_at: Optional[str]
updated_by: str
Resource
class Resource:
def __init__(self,
id: str = '',
name: str = '',
description: str = '',
key: str = '',
enabled: bool = True,
project_id: str = '',
created_by: str = '',
updated_by: str = '',
created_at: Optional[str] = None,
updated_at: Optional[str] = None,
deleted_at: Optional[str] = None):
# ...
Error Handling
The SDK methods raise exceptions with descriptive messages. It's recommended to wrap API calls in try-except blocks:
try:
result = service.verify("code")
# Handle success
except Exception as error:
print(f"API Error: {error}")
# Handle error
Testing
Run the tests using:
python -m pytest python/test_service.py
# or
python -m unittest python/test_service.py
Related Projects
โ Admin UI: go-iam-ui
๐ณ Docker Setup: go-iam-docker
๐ Backend: go-iam
๐ฆ SDK: go-iam-sdk
๐ Examples: go-iam-examples
License
MIT