|
20 | 20 |
|
21 | 21 |
|
22 | 22 | class MyAccountClient: |
| 23 | + """ |
| 24 | + Client for interacting with the Auth0 MyAccount API. |
| 25 | + Handles connected accounts operations including connecting, completing, listing, and deleting accounts. |
| 26 | + """ |
| 27 | + |
23 | 28 | def __init__(self, domain: str): |
| 29 | + """ |
| 30 | + Initialize the MyAccount API client. |
| 31 | +
|
| 32 | + Args: |
| 33 | + domain: Auth0 domain (e.g., 'your-tenant.auth0.com') |
| 34 | + """ |
24 | 35 | self._domain = domain |
25 | 36 |
|
26 | 37 | @property |
27 | 38 | def audience(self): |
| 39 | + """ |
| 40 | + Get the MyAccount API audience URL. |
| 41 | +
|
| 42 | + Returns: |
| 43 | + The audience URL for the MyAccount API |
| 44 | + """ |
28 | 45 | return f"https://{self._domain}/me/" |
29 | 46 |
|
30 | 47 | async def connect_account( |
31 | 48 | self, |
32 | 49 | access_token: str, |
33 | 50 | request: ConnectAccountRequest |
34 | 51 | ) -> ConnectAccountResponse: |
| 52 | + """ |
| 53 | + Initiate the connected account flow. |
| 54 | +
|
| 55 | + Args: |
| 56 | + access_token: User's access token for authentication |
| 57 | + request: Request containing connection details and configuration |
| 58 | +
|
| 59 | + Returns: |
| 60 | + Response containing the connect URI and authentication session details |
| 61 | +
|
| 62 | + Raises: |
| 63 | + MyAccountApiError: If the API returns an error response |
| 64 | + ApiError: If the request fails due to network or other issues |
| 65 | + """ |
35 | 66 | try: |
36 | 67 | async with httpx.AsyncClient() as client: |
37 | 68 | response = await client.post( |
@@ -68,6 +99,20 @@ async def complete_connect_account( |
68 | 99 | access_token: str, |
69 | 100 | request: CompleteConnectAccountRequest |
70 | 101 | ) -> CompleteConnectAccountResponse: |
| 102 | + """ |
| 103 | + Complete the connected account flow after user authorization. |
| 104 | +
|
| 105 | + Args: |
| 106 | + access_token: User's access token for authentication |
| 107 | + request: Request containing the auth session, connect code, and redirect URI |
| 108 | +
|
| 109 | + Returns: |
| 110 | + Response containing the connected account details including ID, connection, and scopes |
| 111 | +
|
| 112 | + Raises: |
| 113 | + MyAccountApiError: If the API returns an error response |
| 114 | + ApiError: If the request fails due to network or other issues |
| 115 | + """ |
71 | 116 | try: |
72 | 117 | async with httpx.AsyncClient() as client: |
73 | 118 | response = await client.post( |
@@ -106,6 +151,24 @@ async def list_connected_accounts( |
106 | 151 | from_param: Optional[str] = None, |
107 | 152 | take: Optional[int] = None |
108 | 153 | ) -> ListConnectedAccountsResponse: |
| 154 | + """ |
| 155 | + List connected accounts for the authenticated user. |
| 156 | +
|
| 157 | + Args: |
| 158 | + access_token: User's access token for authentication |
| 159 | + connection: Optional filter to list accounts for a specific connection |
| 160 | + from_param: Optional pagination cursor for fetching next page of results |
| 161 | + take: Optional number of results to return (must be a positive integer) |
| 162 | +
|
| 163 | + Returns: |
| 164 | + Response containing the list of connected accounts and pagination details |
| 165 | +
|
| 166 | + Raises: |
| 167 | + MissingRequiredArgumentError: If access_token is not provided |
| 168 | + InvalidArgumentError: If take parameter is not a positive integer |
| 169 | + MyAccountApiError: If the API returns an error response |
| 170 | + ApiError: If the request fails due to network or other issues |
| 171 | + """ |
109 | 172 | if access_token is None: |
110 | 173 | raise MissingRequiredArgumentError("access_token") |
111 | 174 |
|
@@ -157,6 +220,21 @@ async def delete_connected_account( |
157 | 220 | access_token: str, |
158 | 221 | connected_account_id: str |
159 | 222 | ) -> None: |
| 223 | + """ |
| 224 | + Delete a connected account for the authenticated user. |
| 225 | +
|
| 226 | + Args: |
| 227 | + access_token: User's access token for authentication |
| 228 | + connected_account_id: ID of the connected account to delete |
| 229 | +
|
| 230 | + Returns: |
| 231 | + None |
| 232 | +
|
| 233 | + Raises: |
| 234 | + MissingRequiredArgumentError: If access_token or connected_account_id is not provided |
| 235 | + MyAccountApiError: If the API returns an error response |
| 236 | + ApiError: If the request fails due to network or other issues |
| 237 | + """ |
160 | 238 |
|
161 | 239 | if access_token is None: |
162 | 240 | raise MissingRequiredArgumentError("access_token") |
@@ -196,6 +274,23 @@ async def list_connected_account_connections( |
196 | 274 | from_param: Optional[str] = None, |
197 | 275 | take: Optional[int] = None |
198 | 276 | ) -> ListConnectedAccountConnectionsResponse: |
| 277 | + """ |
| 278 | + List available connections that support connected accounts. |
| 279 | +
|
| 280 | + Args: |
| 281 | + access_token: User's access token for authentication |
| 282 | + from_param: Optional pagination cursor for fetching next page of results |
| 283 | + take: Optional number of results to return (must be a positive integer) |
| 284 | +
|
| 285 | + Returns: |
| 286 | + Response containing the list of available connections and pagination details |
| 287 | +
|
| 288 | + Raises: |
| 289 | + MissingRequiredArgumentError: If access_token is not provided |
| 290 | + InvalidArgumentError: If take parameter is not a positive integer |
| 291 | + MyAccountApiError: If the API returns an error response |
| 292 | + ApiError: If the request fails due to network or other issues |
| 293 | + """ |
199 | 294 | if access_token is None: |
200 | 295 | raise MissingRequiredArgumentError("access_token") |
201 | 296 |
|
|
0 commit comments