Skip to content

Commit 1c5f2d8

Browse files
chore: fix for review comments (set-1)
1 parent e40942d commit 1c5f2d8

File tree

4 files changed

+510
-68
lines changed

4 files changed

+510
-68
lines changed

examples/MultipleCustomDomains.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,37 @@ async def domain_resolver(context: DomainResolverContext) -> str:
100100
return DOMAIN_MAP.get(hostname, DEFAULT_DOMAIN)
101101
```
102102

103-
> **Note:** In resolver mode, the SDK builds the `redirect_uri` dynamically from the resolved domain. You do not need to set it per request. If you override `redirect_uri` in `authorization_params`, the SDK uses your value as-is.
103+
## Passing store_options
104+
105+
In resolver mode, pass `store_options` to each SDK call so the resolver can inspect the
106+
current request and select the correct domain. If `store_options` are omitted, the resolver
107+
receives empty context (`request_url=None`, `request_headers=None`).
108+
109+
All public SDK methods that interact with sessions or Auth0 endpoints accept `store_options`.
110+
Here is an example using `get_user()`:
111+
112+
```python
113+
# In your route handler, pass the framework request via store_options
114+
store_options = {"request": request, "response": response}
115+
116+
# The SDK calls your domain_resolver with a DomainResolverContext
117+
# built from the request in store_options
118+
user = await client.get_user(store_options=store_options)
119+
```
120+
121+
The same pattern applies to `get_session()`, `get_access_token()`, `start_interactive_login()`,
122+
`logout()`, and all other session-aware methods.
123+
124+
## Redirect URI Requirements
125+
126+
In resolver mode, the SDK does not infer `redirect_uri` from the request. You must provide it
127+
explicitly:
128+
129+
- Set a default `redirect_uri` when constructing `ServerClient`, or
130+
- Pass `redirect_uri` in `authorization_params` for each login call.
131+
132+
Framework wrappers like `auth0-fastapi` handle this automatically by constructing the
133+
`redirect_uri` from the incoming request's host and scheme.
104134

105135
## Resolver Patterns
106136

@@ -273,13 +303,17 @@ async def domain_resolver(context: DomainResolverContext) -> str:
273303

274304
## Session Behavior in Resolver Mode
275305

276-
In resolver mode, sessions are bound to the domain that created them. On each request, the SDK compares the session's stored domain against the current resolved domain:
306+
In resolver mode, sessions are bound to the domain that created them. On each request, the SDK compares the session's stored domain against the current resolved domain. If the domain is missing or does not match:
277307

278-
- `get_user()` and `get_session()` return `None` on domain mismatch.
279-
- `get_access_token()` raises `AccessTokenError` on domain mismatch.
308+
- `get_user()` and `get_session()` return `None`.
309+
- `get_access_token()` raises `AccessTokenError` (code `MISSING_SESSION_DOMAIN` if the session has no stored domain, `DOMAIN_MISMATCH` if the domains differ).
310+
- `get_access_token_for_connection()` raises `AccessTokenForConnectionError` (same codes as above).
311+
- `start_link_user()` and `start_unlink_user()` raise `StartLinkUserError`.
280312
- Token refresh uses the session's stored domain, not the current request domain.
281313

282-
> **Warning:** If you switch from a static domain string to a resolver function, existing sessions that do not include a stored domain continue to work — the SDK treats the absent domain field as valid. New sessions will store the resolved domain automatically. Once old sessions expire, all sessions will be domain-aware.
314+
> **Warning:** If you switch from a static domain string to a resolver function, existing sessions that do not include a stored domain are treated as **missing sessions**. The SDK cannot verify which domain originally created the session, so users will need to re-authenticate. New sessions store the resolved domain automatically.
315+
316+
> **Note:** If a login was started before the switch to resolver mode and completes after, the SDK falls back to the current resolved domain for token exchange. The resulting session will store the resolved domain and work normally going forward.
283317
284318
## Discovery Cache
285319

0 commit comments

Comments
 (0)