Skip to main content
Use the Python SDK release candidate on your server. The account owner approves the accounts and permissions your app requests. Your app then calls the API for a selected linked account.

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 with client.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.

Handle account recovery

An expired OnlyFans session needs an account reconnect, while a revoked authorization needs fresh approval. Follow Handle account reconnects and Handle failed requests. Check whether a post or message completed before you repeat a request whose result was lost. For the full flow in TypeScript, see the Express OAuth source example.