AsyncManagementClient with custom_domain fails every request with TypeError

Open Beginner friendly
#906 0 comments 0 reactions 0 assignees View on GitHub

@RaphaelFakhri is already working on this.

Since Nov 3, 2026.

  • #907 by @RaphaelFakhri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
api, backend

Research direction

Start in AsyncManagementClient.__init__ and inspect how _enforce_custom_domain_whitelist is registered in the httpx.AsyncClient request hooks; compare with the sync ManagementClient behavior. Reproduce with the provided httpx.MockTransport example, then verify requests succeed and Auth0-Custom-Domain is kept on whitelisted paths and removed on other paths.

Written by the indexing model from the issue text.

Description

Description

When you create AsyncManagementClient with custom_domain, every request raises:

TypeError: object NoneType can't be used in 'await' expression

AsyncManagementClient.__init__ adds _enforce_custom_domain_whitelist to the request event hooks of an httpx.AsyncClient. That function is synchronous. httpx.AsyncClient awaits each request hook (await hook(request)), so awaiting the None it returns raises TypeError before the request is sent. The sync ManagementClient is not affected.

Reproduction
import asyncio
import httpx
from auth0.management import AsyncManagementClient

async def main():
    client = AsyncManagementClient(
        domain="tenant.auth0.com",
        token="TOKEN",
        custom_domain="login.example.com",
        httpx_client=httpx.AsyncClient(
            transport=httpx.MockTransport(lambda r: httpx.Response(200, json={}))
        ),
    )
    await client.users.get("auth0|abc123")

asyncio.run(main())

The same error occurs without httpx_client, since the SDK then creates its own httpx.AsyncClient and adds the same hook.

Additional context

Expected: the request is sent, with the Auth0-Custom-Domain header kept on whitelisted paths and removed on other paths, as with ManagementClient.

httpx 0.28.1. Custom domain support was added in #799.

auth0-python version

6.8.0

Python version

3.12

Dominant language
Python
Stars
578
Forks
191
Avg merge
2d 20h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/auth0-python

All issues in auth0/auth0-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.