Install the SDK
Use Python 3.10 or later:Connect a signed-in user
Use a standard confidential OAuth adapter or the SDK’s OAuth helper. Register the exact backend callback and use S256 PKCE. Keep callback state, verifier, initiating application user, session, expiry, and registration version in your application’s ordinary persistence. Before exchange, atomically consume the state for the same trusted user and session. A foreign callback must not consume it. See Connect customers and renew access and the complete Express example.Store and refresh tokens
Your auth framework or application owns persistence and supplies the current access token to the resource SDK. Stable client-bound refresh tokens permit concurrent refresh and retries after a lost response, without a refresh lock or attempt marker. Use conditional writes when the customer replaces or disconnects a registration. Keep client and environment in each customer’s storage key. An invalid refresh grant requires authorization again; temporary storage or network failures can be retried.Choose an account and read its profile
List all shared accounts withclient.linked_accounts.iterate() and let the user choose. Save the selected ID under the same client and user key. Verify the saved choice against the current shared accounts before use.
The client accepts your application’s token getter and selected account:
access_token is your application function that returns its current access token. user_id comes from your app session, and selected_account_id is the user’s verified choice. Do not automatically use the first account returned.
For async code, use AsyncOFAuthClient with async with and await its requests.