Skip to content

Commit f5245dc

Browse files
committed
Add doc comments to my account client
1 parent 167475f commit f5245dc

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

src/auth0_server_python/auth_server/my_account_client.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,49 @@
2020

2121

2222
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+
2328
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+
"""
2435
self._domain = domain
2536

2637
@property
2738
def audience(self):
39+
"""
40+
Get the MyAccount API audience URL.
41+
42+
Returns:
43+
The audience URL for the MyAccount API
44+
"""
2845
return f"https://{self._domain}/me/"
2946

3047
async def connect_account(
3148
self,
3249
access_token: str,
3350
request: ConnectAccountRequest
3451
) -> 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+
"""
3566
try:
3667
async with httpx.AsyncClient() as client:
3768
response = await client.post(
@@ -68,6 +99,20 @@ async def complete_connect_account(
6899
access_token: str,
69100
request: CompleteConnectAccountRequest
70101
) -> 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+
"""
71116
try:
72117
async with httpx.AsyncClient() as client:
73118
response = await client.post(
@@ -106,6 +151,24 @@ async def list_connected_accounts(
106151
from_param: Optional[str] = None,
107152
take: Optional[int] = None
108153
) -> 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+
"""
109172
if access_token is None:
110173
raise MissingRequiredArgumentError("access_token")
111174

@@ -157,6 +220,21 @@ async def delete_connected_account(
157220
access_token: str,
158221
connected_account_id: str
159222
) -> 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+
"""
160238

161239
if access_token is None:
162240
raise MissingRequiredArgumentError("access_token")
@@ -196,6 +274,23 @@ async def list_connected_account_connections(
196274
from_param: Optional[str] = None,
197275
take: Optional[int] = None
198276
) -> 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+
"""
199294
if access_token is None:
200295
raise MissingRequiredArgumentError("access_token")
201296

0 commit comments

Comments
 (0)