Skip to content

Commit c764468

Browse files
committed
Add some docs about managing connected accounts
1 parent a8db5d5 commit c764468

1 file changed

Lines changed: 74 additions & 1 deletion

File tree

examples/ConnectedAccounts.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,79 @@ You can now call the API with your access token and the API can use [Access Toke
111111
```python
112112
access_token_for_google = await server_client.get_access_token_for_connection(
113113
{ "connection": "google-oauth2" },
114-
store_options=store_options
114+
store_options={"request": request, "response": response}
115+
)
116+
```
117+
118+
## Managing Connected Accounts
119+
120+
`ServerClient` exposes three methods for managing a user's connected accounts
121+
122+
### List Available Connections
123+
124+
This method provides a list of connections that have been enabled for use with Connected Accounts for Token Vault that the user may use to connect accounts.
125+
126+
This method requires the My Account `read:me:connected_accounts` scope to be enabled for your application and configured for MRRT.
127+
128+
This method supports paging via optional the use of `take` parameter. Without this parameters, a default page size of 10 is used. Subsequent pages can be retrieved by also passing the `from_token` parameter with the token returned in the `next` property of the response
129+
130+
```python
131+
available_connections = await client.list_connected_account_connections(
132+
take= 5, # optional
133+
from_token= "NEXT_VALUE_FROM_PREVIOUS_RESPONSE", # optional
134+
store_options= {"request": request, "response": response}
135+
)
136+
```
137+
138+
### List Connected Accounts
139+
140+
This method provides a list of accounts that you have already connected.
141+
142+
This method requires the My Account `read:me:connected_accounts` scope to be enabled for your application and configured for MRRT.
143+
144+
An optional `connection` parameter can be used to filter the connected accounts for a specific connection, otherwise all connected accounts will be returns
145+
146+
This method supports paging via optional the use of `take` parameter. Without this parameters, a default page size of 10 is used. Subsequent pages can be retrieved by also passing the `from_token` parameter with the token returned in the `next` property of the response
147+
148+
```python
149+
connected_accounts = await client.list_connected_accounts(
150+
connection= "google-oauth2" # optional
151+
take= 5, # optional
152+
from_token= "NEXT_VALUE_FROM_PREVIOUS_RESPONSE", # optional
153+
store_options= {"request": request, "response": response}
154+
)
155+
```
156+
157+
### Delete Connected Account
158+
159+
This method removes a connected account for the user.
160+
161+
This method requires the My Account `delete:me:connected_accounts` scope to be enabled for your application and configured for MRRT.
162+
163+
This method takes a `connected_account_id` parameter which can be obtained from `list_connected_accounts`.
164+
165+
```python
166+
connected_accounts = await client.delete_connected_account(
167+
connected_account_id= "CONNECTED_ACCOUNT_ID"
168+
store_options= {"request": request, "response": response}
169+
)
170+
```
171+
172+
## A note about scopes
173+
174+
If multiple pieces of Connected Account functionality are intended to be used, it is recommended that you set the default `scope` for the My Account audience when creating you `ServerClient`. This will avoid multiple token requests as without it a new token will be requested for each scope used. This can be done by configuring the `scope` dictionary in the `authorization_params` when configuring the SDK. Each value in the dictionary corresponds to an `audience` and sets the `default` requested scopes for that audience.
175+
176+
```python
177+
server_client = ServerClient(
178+
domain="YOUR_AUTH0_DOMAIN",
179+
client_id="YOUR_CLIENT_ID",
180+
client_secret="YOUR_CLIENT_SECRET",
181+
secret="YOUR_SECRET",
182+
authorization_params={
183+
"scope" {
184+
"https://YOUR_AUTH0_DOMAIN/me/": "create:me:connected_accounts read:me:connected_accounts delete:me:connected_accounts", # scopes required for the My Account audience
185+
# default scopes for custom API audiences can also be defined
186+
}
187+
}
115188
)
116189
```

0 commit comments

Comments
 (0)