profile:read permission and a linked account ID from Connect an account.
Install the release candidate
Read the current profile
SetOFAUTH_ACCESS_TOKEN and OFAUTH_LINKED_ACCOUNT_ID in your server’s environment. Save this as profile.py and run python profile.py:
with block closes the client when you finish.
Check the result
The program prints the account ID, username, and name. Missing JSON values appear as PythonNone. This request does not change the account.
If the API returns an error, the SDK raises OFAuthAPIError. Read its code, recovery_action, and request_id. Follow Handle failed requests to choose the next step. Check whether a message or post was created before repeating a request whose result you did not receive.
Use the client in your application
Useiterate() to read all pages of a list. Inside the same with block, list the accounts shared through this authorization:
client.with_linked_account(account_id) to select another account shared through the same authorization. For async code, use AsyncOFAuthClient with async with and await its requests.
Connect customers and renew access
Use the SDK’s OAuth helper or a standard confidential OAuth client with the authorization-code contract. Persist callback state and PKCE against the initiating application user and browser session, with expiry and single use. Validate the issuer and exact redirect URI before exchange. Your auth framework or application owns token persistence and refresh. Supply its current access token to the resource client. Use the returnedexpires_in, and refresh through the form-encoded token endpoint. Code exchanges always return a refresh token.
The refresh token is stable and bound to the authenticated client. Independent instances can refresh concurrently; retry a lost refresh response with the same token. No database refresh lock, attempt marker, or replay journal is required. Use ordinary conditional writes so an earlier refresh cannot replace a registration the customer has changed or disconnected.
Keep client and environment in each application’s customer storage key. Discover all granted accounts, then persist an explicit account choice. An account ID does not choose authority or billing.
Revoking a refresh token ends that credential and its access tokens. Ending the authorization ends all its credentials. A provider session error requires account reconnect, which does not renew OAuth or replay a write. See the Express source example for the complete backend journey.