Skip to main content

🔐 goiam-python

PyPI version Python versions

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

Metadata

Release files for goiam-python 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for goiam-python 0.3.0
File Size Uploaded Provenance Actions
goiam_python-0.3.0.tar.gz 11.1 kB Without provenance Details for goiam_python-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for goiam-python 0.3.0
File Interpreter ABI Platform Actions
goiam_python-0.3.0-py3-none-any.whl Python 3 none any Details for goiam_python-0.3.0-py3-none-any.whl

Total release size: 18.6 kB

Release files / goiam_python-0.3.0.tar.gz

Download URL goiam_python-0.3.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9ccac99377338102f66848243b942c5af74e990170e39d26cc94571b311fd4aa
BLAKE2b-256 checksum
How to use checksums
0c5d7d729a9d762741648051c4f0b23ca132378edee1edd2d02b5cb556b9f3a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / goiam_python-0.3.0-py3-none-any.whl

Download URL goiam_python-0.3.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1b280b9b6784aef616d1d3d42ca456418c7f13697d3996d3701b75d40c98b0a
BLAKE2b-256 checksum
How to use checksums
bffee00937a014b1c3245940e4b0be3291a6ef6c19f392b7d38a2dfdd3242256
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for goiam-python 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page