Skip to main content

Overview

Hosted Mode provides the simplest integration path for OnlyFans authentication. Users are redirected to OFAuth’s secure authentication pages, reducing your security burden while providing a seamless authentication experience.
Prefer a popup experience? Use our Link Embed Library to keep users in your app rather than redirecting them away from your site.

How It Works

  1. Initialize: Create a link session with your redirect URL
  2. Redirect/Popup: Send users to OFAuth’s secure authentication page
  3. Authentication: Users complete authentication on OFAuth’s pages
  4. Return: Users are redirected back to your URL with status and connection details
  5. Process: Handle the query params to complete the flow

Integration Options

Hosted Mode offers two integration approaches to fit your application’s user experience:

Redirect Integration

Traditional Flow - Redirect users to OFAuth’s authentication pages. Perfect for web applications and simple mobile integrations.

Popup/Embed Integration

Seamless UX - Use our Embed SDK to display authentication in a popup or iframe. Keeps users in your application throughout the flow.

Base URL

https://api.ofauth.com/v2/link

Authentication

All requests require your API key header:
apikey: YOUR_API_KEY

Core Endpoints

Initialize Hosted Session

Create a new hosted authentication session.

Redirect Query Parameters

After authentication completes, OFAuth redirects users to your URL with query parameters.

All Parameters

ParameterTypePresentDescription
statusstringAlwayssuccess, cancelled, or error
connection_idstringOn successThe connection ID to use with Access API
client_reference_idstringIf providedYour internal user identifier from /init
stepstringOn cancelWhere the user exited the flow
error_codestringOn errorMachine-readable error identifier

Status Values

ValueMeaning
successAuthentication completed, connection_id is available
cancelledUser exited the flow, check step for where
errorSomething went wrong, check error_code

Step Values (when status=cancelled)

ValueDescription
pre-loginBefore entering credentials
loginDuring credential entry
2faDuring two-factor authentication
authorizationReviewing permissions

Error Codes (when status=error)

CodeDescription
session_expiredLink session expired (1 hour limit)
invalid_credentialsUser entered wrong credentials
account_lockedOnlyFans account is locked
2fa_failedTwo-factor authentication failed

Retrieve Session Status

Check the current status of a hosted session.

Delete Session

Clean up a hosted session.

Security: Allowed Redirect URIs

Your redirectUrl must be pre-registered in your OFAuth dashboard as an Allowed Redirect URI.

Exact Match

We require exact URL matches (scheme, host, path). Query parameters are added by OFAuth on redirect.

HTTPS Required

Always use HTTPS in production. Configure multiple URLs for different environments.
Configure Allowed Redirect URIs per platform in the OFAuth dashboard under Developers → API.

Misconfiguration Behavior

  • If you pass a redirectUrl not on your allowlist, /v2/link/init returns 400 with Link is misconfigured.
  • If no Allowed Redirect URIs are configured, you must add at least one before using Link.

Implementation Guide

Step 1: Initialize the Session

const initResponse = await fetch("https://api.ofauth.com/v2/link/init", {
	method: "POST",
	headers: {
		apikey: "YOUR_API_KEY",
		"Content-Type": "application/json"
	},
	body: JSON.stringify({
		redirectUrl: "https://yourapp.com/callback",
		clientReferenceId: "user_123"
	})
})

const { url } = await initResponse.json()

Step 2: Redirect User to Authentication

After initialization, redirect the user to the authentication URL:
window.location.href = url // Redirect to authentication page

Step 3: Handle the Callback

When users complete or cancel authentication, they’ll be redirected to your URL with query params:
// User visits: https://yourapp.com/callback?status=success&connection_id=conn_abc123&client_reference_id=user_123

const params = new URLSearchParams(window.location.search)
const status = params.get("status")
const connectionId = params.get("connection_id")
const clientReferenceId = params.get("client_reference_id")

if (status === "success" && connectionId) {
	// Store connection ID for future API calls
	localStorage.setItem("connectionId", connectionId)
	// Redirect to dashboard or next step
	window.location.href = "/dashboard"
} else if (status === "cancelled") {
	const step = params.get("step")
	console.log(`User cancelled at: ${step}`)
	// Show appropriate message
} else if (status === "error") {
	const errorCode = params.get("error_code")
	console.error(`Authentication failed: ${errorCode}`)
	// Handle error
}

Integration Examples

React Component

import { useState } from "react"

function ConnectOnlyFansButton({ userId }) {
	const [isLoading, setIsLoading] = useState(false)

	const handleConnect = async () => {
		setIsLoading(true)

		try {
			const response = await fetch("/api/auth/init", {
				method: "POST",
				headers: { "Content-Type": "application/json" },
				body: JSON.stringify({ userId })
			})

			const { url } = await response.json()
			window.location.href = url
		} catch (error) {
			console.error("Failed to initialize authentication:", error)
			setIsLoading(false)
		}
	}

	return (
		<button
			onClick={handleConnect}
			disabled={isLoading}
			className="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
			{isLoading ? "Connecting..." : "Connect OnlyFans Account"}
		</button>
	)
}

Security Best Practices

Server-Side Verification

Always verify session status server-side, never trust client-side data

HTTPS Only

Use HTTPS for all redirect URLs and API communications

Session Expiry

Link sessions expire after 1 hour for security

State Management

Store connection IDs securely in your database

Error Handling

{
  "error": "Session expired",
  "code": "SESSION_EXPIRED"
}
Solution: Create a new session with /init
{
  "error": "Link is misconfigured: invalid redirect URL"
}
Solution: Add the URL to your Allowed Redirect URIs in the dashboard
User is redirected with ?status=error&error_code=invalid_credentialsSolution: User needs to retry authentication with correct credentials

Testing

Sandbox Mode: Use sandbox API keys for development. Test sessions work with demo credentials that are provided on the hosted authentication page.

Next Steps

Looking for a fully custom experience? Enterprise Whitelabel mode is available for approved partners who need direct control over authentication flows.