> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ofauth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Security

> Keep app secrets, tokens, and account access safe.

Keep your app's client secret and sign-in checks on your server, also called the backend. Account owners approve access on an OFAuth page. Your app can use only the accounts and permissions they share.

## Which accounts a token can access

An access token belongs to one authorization: the accounts and permissions an owner approved. It also belongs to one mode, such as Sandbox or Live. The `x-linked-account-id` header selects one of those accounts. The ID alone does not grant access.

The linked-account list shows only accounts shared through that authorization. Removing an account from the list ends access through that authorization. It does not delete the OnlyFans account or remove access through other authorizations.

## Keep each value in the right place

| Value | Your backend | Browser or native app |
| - | - | - |
| Client ID, authorization URL, requested scopes | Build the authorization request. | Open the authorization URL. |
| Client secret and PKCE verifier | Keep these secret values and use them to exchange the callback code. | Do not expose. |
| OAuth state | Save it with the browser session that started the request. Accept it only once. | Returns in the callback URL. |
| Access and refresh tokens | Store securely and use for API calls. | Do not expose. |

Before using an account, check the callback's state and exchange its code on your server. Receiving a callback alone does not prove that access was approved.

## Protect the callback

PKCE protects the callback code with a secret created for each sign-in attempt. Use the required `S256` method and the exact callback URL registered for your app.

`state` is a random value that ties the callback to the browser session that started sign-in. Save it with that session and accept it only once. Reject missing, expired, changed, or reused values.

Authorization codes work once and expire after five minutes. Exchange the code on your server. Keep the PKCE verifier and client secret out of browsers and mobile app storage. See [Authorize](https://docs.ofauth.com/v3/api-reference/link/authorize.md).

## Protect tokens

Access tokens are opaque Bearer secrets with a 15-minute lifetime. Refresh tokens stay stable and expire after 90 days without successful authenticated refresh. They are restricted to confidential clients. Independent backend instances can refresh concurrently and retry a lost response.

Stable refresh has a security tradeoff: a stolen refresh token plus client secret can renew until revocation or expiry. An access token can be replayed without a secret until expiry or server-side revocation. Store both privately and protect normal registration changes with conditional writes.

Keep secrets out of logs and tokens out of URLs. Reject authenticated resource redirects, including 307 and 308. Send client secrets and refresh tokens only to their designated OAuth endpoints. See [Tokens](https://docs.ofauth.com/v3/api-reference/link/tokens.md).

## Check access in your app

Before each API call, check that the user in your app can use the saved account access. Ask for only the permissions your feature needs. Keep Sandbox, Test, and Live credentials and account records separate.

Check [webhook signatures](https://docs.ofauth.com/v3/api-reference/webhooks.md) before acting on account or access changes. Stop using access when an owner removes an account or ends approval. Use [revoke](https://docs.ofauth.com/v3/api-reference/link/tokens.md#revoke) to end a credential, or [remove a linked account](https://docs.ofauth.com/v3/api-reference/account/linked-accounts.md#remove-a-linked-account) to end access to just one account.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.