You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SDK supports [Auth0 Organizations](https://auth0.com/docs/organizations) with first-class `organization` and `invitation` parameters on `ServerClient` and `StartInteractiveLoginOptions`. Token claim validation is enforced automatically at callback. For setup, invitation flows, error handling, and reading org data from the session, see [examples/InteractiveLogin.md](examples/InteractiveLogin.md#8-organizations).
110
+
107
111
### 4. Login with Custom Token Exchange
108
112
109
113
If you're migrating from a legacy authentication system or integrating with a custom identity provider, you can exchange external tokens for Auth0 tokens using the OAuth 2.0 Token Exchange specification (RFC 8693):
Copy file name to clipboardExpand all lines: examples/InteractiveLogin.md
+101-6Lines changed: 101 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Interactive Login
2
2
3
-
Interactive login in `auth0‑server‑python` is a two‑step process. First, you start the login flow by obtaining an authorization URL; then, after the user authenticates at Auth0 and is redirected back, you complete the login flow to exchange the authorization code for tokens.
3
+
Interactive login in `auth0‑server‑python` is a two‑step process. First, you start the login flow by obtaining an authorization URL; then, after the user authenticates at Auth0 and is redirected back, you complete the login flow to exchange the authorization code for tokens.
4
4
5
-
This guide covers how to customize the authorization parameters, pass custom app state, enable **Pushed Authorization Requests (PAR)** and **Rich Authorization Requests (RAR)**, and supply store options.
5
+
This guide covers how to customize the authorization parameters, pass custom app state, enable **Pushed Authorization Requests (PAR)** and **Rich Authorization Requests (RAR)**, supply store options, and log in to an organization.
6
6
7
7
## 1. Starting Interactive Login
8
8
@@ -28,7 +28,7 @@ Now call `start_interactive_login()` to obtain the authorization URL and redirec
> Using PAR requires that your Auth0 tenant is configured to support it. Refer to Auth0’s documentation for details.
92
+
> Using PAR requires that your Auth0 tenant is configured to support it. Refer to Auth0's documentation for details.
93
93
94
94
## 5. Using Pushed Authorization Requests and Rich Authorization Requests (RAR)
95
95
@@ -137,4 +137,99 @@ print(result.get("authorization_details")) # Rich Authorization Re
137
137
```
138
138
139
139
>[!NOTE]
140
-
>The `callback_url` must include the necessary parameters (`state`and`code`) that Auth0 sends upon successful authentication.
140
+
>The `callback_url` must include the necessary parameters (`state`and`code`) that Auth0 sends upon successful authentication.
141
+
142
+
## 8. Organizations
143
+
144
+
[Auth0 Organizations](https://auth0.com/docs/organizations) lets you manage teams, business customers, and partner companies as distinct entities with their own login flows and membership.
145
+
146
+
### Logging in to an organization
147
+
148
+
Set `organization` on `ServerClient` to enforce it for every login (dedicated-org), orpass it per login via `StartInteractiveLoginOptions` (multi-org):
149
+
150
+
```python
151
+
from auth0_server_python.auth_server.server_client import ServerClient
152
+
from auth0_server_python.auth_types import StartInteractiveLoginOptions
153
+
154
+
# Dedicated-org: every login enforces this organization
`organization` accepts either an org ID (`org_` prefix) or an org name. The SDK validates the corresponding `org_id`or`org_name` claim in the returned token automatically at callback.
172
+
173
+
> [!IMPORTANT]
174
+
> In the multi-org pattern, validate that the `organization` value comes from a trusted source — never pass it unvalidated directly from user input.
175
+
176
+
### Accepting an invitation
177
+
178
+
When a user follows an invitation link, extract `organization`and`invitation`from the URLandpass them as typed fields:
Auth0 returns organization errors as standard OAuth error responses (`error`+`error_description`). The SDK surfaces these as`ApiError`, preserving the raw values so you can branch on `error.code`:
196
+
197
+
```python
198
+
from auth0_server_python.error import ApiError, OrganizationTokenValidationError
|`OrganizationTokenValidationError`|`org_id`/`org_name`in the returned token does not match what was requested |
217
+
|`ApiError`| Auth0 rejected the authorization request — inspect `error.code`and`error.message`for the raw OAuth error and description |
218
+
219
+
Common `ApiError.code` values for org flows:
220
+
221
+
|`error.code`| Typical cause |
222
+
|---|---|
223
+
|`access_denied`| User not a member, connection not enabled for org, member quota exceeded |
224
+
|`invalid_request`| Invalid org format, feature disabled, client not configured for orgs, expired or invalid invitation ticket |
225
+
226
+
### Reading organization data from the session
227
+
228
+
After a successful org login, `org_id`is always present in the token. `org_name`is also present when the organization has the org name feature enabled:
229
+
230
+
```python
231
+
user = await auth0.get_user(store_options={"request": request, "response": response})
232
+
if user:
233
+
print(user.get("org_id")) # always present; use as stable identifier
234
+
print(user.get("org_name")) # present when org name is enabled
0 commit comments