Skip to main content

IAM V2 client library for EaseCation services (Python port of @easecation/iam-client)

Project description

easecation-iam-client

Python port of @easecation/iam-client. IAM V2 API wrapper for EaseCation services.

Install

pip install easecation-iam-client

Or from repo:

pip install -e packages/iam-client-py

Usage

from easecation_iam_client import IamClient, create_iam_client_from_env

# From env (IAM_BASE_URL, IAM_CLIENT_ID, IAM_CLIENT_SECRET)
client = create_iam_client_from_env()

# Or explicit config
client = IamClient(
    iam_base_url="https://iamapi.easecation.net",
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

# API-key-only Open V2 Data calls do not require client_id/client_secret.
api_key_only_client = IamClient(
    iam_base_url="https://iamapi.easecation.net",
    api_key="ec_xxx",
)
feishu_users = api_key_only_client.request_open_v2_data(
    "/feishu/batch",
    body={"uids": [123]},
)

# Or override the API key for one request.
permission_users = client.request_open_v2_data(
    "/permission/user",
    api_key="ec_xxx",
    body={"permission_code": "5#sen.admin"},
)

# OAuth code exchange
tokens = client.exchange_oauth_code(code, redirect_uri)

# Verify access token
verify = client.verify_token(access_token)

# API key verification
api_key_data = client.verify_api_key(key_value)

# App session verification
valid = client.verify_app_session_token(app_session_token)

# Cross-app callback with IAM-managed API key refresh/retry.
player = client.with_app_api_key(
    lambda api_key: ecapi.player.get_info(
        {"displayName": "Steve"},
        auth={"type": "apiKey", "apiKey": api_key},
    ),
    name="service -> ECAPI",
)

API

  • get_app_session_token(), invalidate_app_token()
  • exchange_oauth_code(code, redirect_uri)
  • verify_token(access_token), evict_from_verify_cache(access_token)
  • refresh_token(refresh_token), revoke_token(refresh_token)
  • get_jwks(), get_user_profile(access_token), get_user_bootstrap(...), get_hr_bootstrap_data(...)
  • verify_iam_callback_token(iam_token, ...), get_user_permissions(user_id, ...)
  • verify_api_key(key_value), evict_api_key_from_cache(key_value), clear_api_key_cache()
  • verify_app_session_token(app_session_token), clear_app_session_verify_cache()
  • get_app_api_key(...), with_app_api_key(callback, ...)
  • request_open_v2_data(path, api_key=..., body=..., params=..., method=...)

ApiKeyRotationHelper for zero-downtime key rotation: create_new_key(...), revoke_key(key_id, ...), list_active_keys(owner_id?).

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

easecation_iam_client-1.4.3.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easecation_iam_client-1.4.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file easecation_iam_client-1.4.3.tar.gz.

File metadata

  • Download URL: easecation_iam_client-1.4.3.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for easecation_iam_client-1.4.3.tar.gz
Algorithm Hash digest
SHA256 eca596e061970ed35afe4d3ff7db8b25256e36014641e4feaa3035e1c6f0712b
MD5 2be5b6a57f9591ec5a8046d3f314ba31
BLAKE2b-256 2ed73e8cf5ce1ee60509eecdc6f7602de132041146ba9eb0101d62ed9e0a7471

See more details on using hashes here.

File details

Details for the file easecation_iam_client-1.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for easecation_iam_client-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b9efa955c0cf35a67c360f9d48f9fc143a20e4b001bf21a29db5491724a61c63
MD5 36e6f3c77373292bc4b2f049a6dc482b
BLAKE2b-256 682247c35565cefe46dcce8428dcb54d2de6a40633df96b260b87693b3729809

See more details on using hashes here.

Supported by

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