Skip to main content

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",
)

# Business delegation: app A calls app B as an authorized user without seeing
# the user's own API key. Requirements:
# 1. User OAuth-authorized app A with scope "<target_app_id>.permission".
# 2. App B granted app A scope "iam.business.delegate" in App Grants.
me_response = client.request_with_delegated_user_api_key(
    "https://ecapi.example.test/users/me",
    api_key="ec_app_key_for_app_a",  # optional; omit to use config api_key/get_app_api_key()
    user_id=123,
    target_application_id=5,
)
me = me_response.json()

Reverse-search a registered data type:

result = client.search_user_data({
    "data_code": "channel_ids",
    "filter": {"path": "$", "operator": "array_contains", "value": "频道B"},
})

Resolve a tenant-scoped Feishu identity:

result = client.resolve_feishu_identities({
    "identities": [{"user_id": "tenant_user_id", "organization": "宁波易什"}],
})

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, ...)
  • get_delegated_user_api_key(...), get_delegated_user_api_key_data(...)
  • request_with_delegated_user_api_key(url, api_key=..., user_id=..., target_application_id=..., ...)
  • request_open_v2_data(path, api_key=..., body=..., params=..., method=...)
  • search_user_data(request, api_key=...)
  • resolve_feishu_identities(request, api_key=...)

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

Release files for easecation-iam-client 1.5.3

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

Source distribution (sdist)

Source distribution for easecation-iam-client 1.5.3
File Size Uploaded
easecation_iam_client-1.5.3.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easecation-iam-client 1.5.3
File Interpreter ABI Platform
easecation_iam_client-1.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / easecation_iam_client-1.5.3.tar.gz

Download URL easecation_iam_client-1.5.3.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
99ae4e4ab1045368aca2deafaa3f092c9eefd88edebda0533516c5c481bb21c3
BLAKE2b-256 checksum
How to use checksums
679f1c1f964ee770d3fce0f237ab5e2b21e6d60206e0fb992a9cc46a95392dff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / easecation_iam_client-1.5.3-py3-none-any.whl

Download URL easecation_iam_client-1.5.3-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
708b21c0bf8fd1d68389f8c477f05e65972a96a74d0fa420d370bd74092f4771
BLAKE2b-256 checksum
How to use checksums
86e3e18f1e9b52b2559c88de17ec5871f6d9de07815ea6f13cac444ac70d67be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

1.5.13

2 release files

1.5.12

2 release files

1.5.11

2 release files

1.5.10

2 release files

1.5.9

2 release files

1.5.8

2 release files

1.5.7

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

This release

1.5.3 This release

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.0.0

2 release files

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