Skip to main content

Unofficial Asyncronous Python Client for Logto

Project description

aiologto

Unofficial Asyncronous Python Client for Logto

Latest Version: PyPI version

Features

  • Unified Asyncronous and Syncronous Python Client for Logto
  • Supports Python 3.6+
  • Strongly Typed with Pydantic
  • Includes Function Wrappers to quickly add to existing projects
  • Utilizes Environment Variables for Configuration

Installation

# Install from PyPI
pip install aiologto

# Install from source
pip install git+https://github.com/GrowthEngineAI/aiologto.git

Usage

WIP - Simple Usage Example

import asyncio
from aiologto import Logto, UserListResponse
from aiologto.utils import logger

"""
Environment Vars that map to Logto.configure:
all vars are prefixed with LOGTO_


LOGTO_URL (url): str takes precedence over LOGTO_SCHEME | LOGTO_HOST | LOGTO_PORT
LOGTO_SCHEME (scheme): str - defaults to 'http://'
LOGTO_HOST (host): str - defaults to None
LOGTO_PORT (port): int - defaults to 3000

LOGTO_APP_ID (app_id): str
LOGTO_APP_SECRET (app_secret): str
LOGTO_RESOURCE (resource): str - defaults to "https://api.logto.io"
LOGTO_OIDC_GRANT_TYPE (oidc_grant_Type): str - defaults to "client_credentials"

## these variables are dynamically generated from the oidc
LOGTO_ACCESS_TOKEN (access_token): str - defaults to None
LOGTO_TOKEN_TYPE (token_type): str - defaults to None

LOGTO_JWT_ALGORITHMS (jwt_algorithms): str - defaults to None
LOGTO_JWT_OPTIONS (jwt_options): dict - defaults to {"verify_at_hash": False}
LOGTO_JWT_ISSUER (jwt_issuer): str - defaults to generated value

LOGTO_TIMEOUT (timeout): int - defaults to 10
LOGTO_IGNORE_ERRORS (ignore_errors): bool = defaults to False

"""

Logto.configure(
    url = '...',
    app_id = "...",
    app_secret = "...",
    debug_enabled = True,
)

async def fetch_users():
    
    # Fetch all the users
    users: UserListResponse = await Logto.users.async_list()
    logger.info(f"Users: {users}")

    # Update a specific user
    user = users[0]
    user.custom_data["email"] = "gexai@example.com"

    user = await Logto.users.async_update(user)
    logger.info(f"User Updated: {user.dict()}")


asyncio.run(fetch_users())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiologto-0.0.6.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

aiologto-0.0.6-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file aiologto-0.0.6.tar.gz.

File metadata

  • Download URL: aiologto-0.0.6.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aiologto-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2dfa57c0d22ea186a1e7a8678ba71b4ab2e106f2d0ec10ea4e89a436e4c54113
MD5 9c4ee81e1aaf8d7ae508367b1dce9b1f
BLAKE2b-256 9eb8a68bf3366886bf947d8ca7dbc78fd117613c9b206a5eaca52cb04c723cf5

See more details on using hashes here.

File details

Details for the file aiologto-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: aiologto-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aiologto-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7138487ba373c0dc7cbcb6f7ffdd7b145ac46d5c00e736cf7ef85da895c4d64b
MD5 1b6e91fedf3ccb9f7b6de99863553fc2
BLAKE2b-256 598e87fb0fdc847b3f7b55307ff4d53470e6808fc1842d15b3d099c256c29bea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page