OnlyFans Authentication
Integrating OFAuth into your application
This guide will walk you through the process of implementing OnlyFans authentication using OFAuth's Account Linking Service. Please note that this is a beta feature and is subject to change.
Prerequisites
Before you begin, make sure you have:
- Generated an access key with Account Linking permissions
- Set up a webhook URL to receive users' session data
Implementation Steps
Step 1: Generate a Client Session
Create an endpoint in your application to generate a client session:
- Make a POST request to
https://auth-api.ofauth.com/init
- Include the following headers:
Content-Type: application/json
apiKey: your_api_key_here
- Send this JSON body:
- You'll receive a response with a
clientSecret
,url
, andexpiresAt
timestamp.
Step 2: Capture login credentials
At this point, you have two options for implementing the login flow:
Option 1: Using the Embed Library (Recommended)
You can integrate OFAuth's login directly into your website using our embed library. There are two ways to implement this:
Simple Implementation (Code Snippet)
Add this HTML snippet to your website:
This will create a "Link Account" button that opens an inline login popup when clicked.
Advanced Implementation (JavaScript Library)
For more advanced projects (like React applications), install the Link embed library:
Then implement it in your code:
You can style the trigger element any way you want, just make sure to keep the
data-ofauth-login
attribute.
Option 2: Redirect to a hosted Link form
Alternatively, you can redirect users directly to the authentication URL received in Step 1. Just make sure to include the successUrl
and returnUrl
parameters when creating the client session.
Step 3: Handle Webhook Events
- Create an endpoint in your backend to receive webhook events
- OFAuth will send a POST request to your webhook URL with this structure:
- In your webhook handler:
- Verify the
secret
matches your webhook secret - Use the
metadata
to identify the user - Save the
session
data securely for future API requests
- Verify the
Managing Active Accounts
You can view and manage authenticated accounts from your OFAuth dashboard:
- See active sessions
- View session data
- Terminate sessions (log out users)
Need Help?
If you encounter any issues or have questions, please contact our support team.