Skip to main content

Auth0 My Organization Python SDK

Project description

Python SDK for Auth0 MyOrganization

pypi License fern shield

📚 Documentation • 🚀 Getting Started • 💬 Feedback


Documentation

  • Docs Site - explore our docs site and learn more about Auth0
  • API Reference - full reference for this library

Getting Started

Requirements

This library supports the following tooling versions:

  • Python >= 3.10

Installation

pip install myorganization-python

Configure the SDK

The MyOrganizationClient is the recommended way to interact with the Auth0 My Organization API. It provides a simpler interface using just your Auth0 domain:

from auth0.myorganization import MyOrganizationClient

# With an access token (from your authentication flow)
client = MyOrganizationClient(
    domain="your-tenant.auth0.com",
    token=user_access_token,
)

For backend scripts or admin tooling, you can use client credentials with automatic token management:

# With client credentials (automatic token acquisition and refresh)
client = MyOrganizationClient(
    domain="your-tenant.auth0.com",
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    organization="YOUR_ORG_ID",
)

Then use the client to interact with the API:

# List organization domains
domains = client.organization.domains.list()

# Get organization details
details = client.organization_details.get()

Using the Base Client

For more control, you can use the Auth0 client directly with a full base URL:

from auth0.myorganization import Auth0

client = Auth0(
    base_url="https://your-tenant.auth0.com/my-org",
    token="YOUR_TOKEN",
)
client.organization.domains.create(
    domain="acme.com",
)

Async Client

The SDK also exports async clients so that you can make non-blocking calls to the API. Note that if you are constructing an Async httpx client class to pass into this client, use httpx.AsyncClient() instead of httpx.Client() (e.g. for the httpx_client parameter of this client).

import asyncio

from auth0.myorganization import AsyncMyOrganizationClient

client = AsyncMyOrganizationClient(
    domain="your-tenant.auth0.com",
    token="YOUR_TOKEN",
)


async def main() -> None:
    details = await client.organization_details.get()
    print(details)


asyncio.run(main())

You can also use the base async client directly:

import asyncio

from auth0.myorganization import AsyncAuth0

client = AsyncAuth0(
    base_url="https://your-tenant.auth0.com/my-org",
    token="YOUR_TOKEN",
)


async def main() -> None:
    await client.organization.domains.create(
        domain="acme.com",
    )


asyncio.run(main())

Request and Response Types

The SDK exports all request and response types as Pydantic models. You can import them directly:

from auth0.myorganization import MyOrganizationClient
from auth0.myorganization.types import GetOrganizationDetailsResponseContent

client = MyOrganizationClient(
    domain="your-tenant.auth0.com",
    token="YOUR_TOKEN",
)

details: GetOrganizationDetailsResponseContent = client.organization_details.get()
print(details.display_name)

API Reference

Key Classes

  • MyOrganizationClient - recommended client for managing organization details, domains, identity providers, and configuration
  • AsyncMyOrganizationClient - async variant of the above
  • TokenProvider - automatic token management via OAuth 2.0 client credentials grant

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.

from auth0.myorganization.core.api_error import ApiError

try:
    client.organization.domains.create(...)
except ApiError as e:
    print(e.status_code)
    print(e.body)

Advanced

Access Raw Response Data

The SDK provides access to raw response data, including headers, through the .with_raw_response property. The .with_raw_response property returns a "raw" client that can be used to access the .headers and .data attributes.

from auth0.myorganization import Auth0

client = Auth0(
    base_url="https://your-tenant.auth0.com/my-org",
    token="YOUR_TOKEN",
)
response = client.organization.domains.with_raw_response.create(...)
print(response.headers)  # access the response headers
print(response.status_code)  # access the response status code
print(response.data)  # access the underlying object

Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Use the max_retries request option to configure this behavior.

client.organization.domains.create(..., request_options={
    "max_retries": 1
})

Timeouts

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

from auth0.myorganization import MyOrganizationClient

client = MyOrganizationClient(
    domain="your-tenant.auth0.com",
    token="YOUR_TOKEN",
    timeout=20.0,
)


# Override timeout for a specific method
client.organization.domains.create(..., request_options={
    "timeout_in_seconds": 1
})

Additional Headers

If you would like to send additional headers as part of the request, use the headers parameter:

client = MyOrganizationClient(
    domain="your-tenant.auth0.com",
    token="YOUR_TOKEN",
    headers={"X-Custom-Header": "custom value"},
)

Logging

The SDK includes built-in logging that can help with debugging. You can enable it by passing a logging configuration when creating the client:

from auth0.myorganization import Auth0

client = Auth0(
    base_url="https://your-tenant.auth0.com/my-org",
    token="YOUR_TOKEN",
    logging={"level": "debug"},
)

When enabled at debug level, the SDK logs HTTP request and response details including method, URL, status code, and headers. Sensitive information (authorization headers, API keys) is automatically redacted.

Custom Client

You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.

import httpx
from auth0.myorganization import MyOrganizationClient

client = MyOrganizationClient(
    domain="your-tenant.auth0.com",
    token="YOUR_TOKEN",
    httpx_client=httpx.Client(
        proxy="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

What is Auth0?

Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0

Copyright 2026 Okta, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0

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

myorganization_python-1.0.0.tar.gz (102.5 kB view details)

Uploaded Source

Built Distribution

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

myorganization_python-1.0.0-py3-none-any.whl (224.2 kB view details)

Uploaded Python 3

File details

Details for the file myorganization_python-1.0.0.tar.gz.

File metadata

  • Download URL: myorganization_python-1.0.0.tar.gz
  • Upload date:
  • Size: 102.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for myorganization_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 db902471aeb81180085c0a7d44c27932230d1e9b6cfe74297ca14cc3a7436dac
MD5 012d764e80689545dbdef7b78dfa05a2
BLAKE2b-256 8541dd6e8775043e0a93c5d3a05f074c95bdd7ce77ead92a1b1e34370d4728cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for myorganization_python-1.0.0.tar.gz:

Publisher: publish.yml on auth0/myorganization-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file myorganization_python-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for myorganization_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ce0f3811e987c873e2aa8f267114849ad4e34118506493268d2417238b741ff
MD5 fdc2211e8a4845a737f344d6c3ab54d4
BLAKE2b-256 692c90697c9f956bb17ae68b491ad6fb49d47d4d521833be8dd3a7a165f6d412

See more details on using hashes here.

Provenance

The following attestation bundles were made for myorganization_python-1.0.0-py3-none-any.whl:

Publisher: publish.yml on auth0/myorganization-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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