If your platform creates Firecrawl accounts for its users and pays for their usage, use Firecrawl for Platforms instead. OAuth is for users who bring their own Firecrawl account. To compare OAuth with API keys and MCP sign-in, see Authentication.
Overview
Scopes
A token can do anything an API key on that team can do. Request only what you need and keep tokens on your server.
Register your app
Your app needs aclient_id. There are two ways to get one, and neither needs approval from Firecrawl.
- Dynamic Client Registration
- Client ID Metadata Document
Register once with RFC 7591 and store the The
client_id it returns.client_name is what users see on the consent screen.http://localhost and other loopback addresses are allowed for local development. A redirect URI may not contain a fragment or user info, and the URI you send at authorization must match a registered one exactly.
Authorize
Generate a PKCEcode_verifier and its S256 code_challenge, then send the user’s browser to the authorization endpoint.
The user signs in if needed, chooses a team, and approves. Firecrawl then redirects to your
redirect_uri with code and state. The code is valid for a short time and only once.
If the user cancels, Firecrawl redirects with error=access_denied.
Exchange the code
application/x-www-form-urlencoded or JSON.
user_id and team_id identify who authorized and which team is billed. Store both tokens server-side.
Call the API
Send the access token as a bearer token, exactly like an API key.new Firecrawl({ apiKey: "fco_..." }).
Refresh
Access tokens expire after one hour. Exchange the refresh token for a new pair before or after expiry.refresh_token from the response. Using a refresh token a second time is treated as a stolen token: Firecrawl revokes the whole connection, including the tokens the first refresh just returned, and the user has to connect your app again. Serialize refreshes per connection and never retry a refresh that returned invalid_grant.
Revoke
Call the revocation endpoint (RFC 7009) when the user disconnects Firecrawl in your app. Send the refresh token: that revokes the whole connection, including its access token and the key behind it. Sending an access token only invalidates that access token; the refresh token keeps working and the connection stays listed in the user’s Settings.200 even when the token is unknown or already revoked. Users can also revoke your app under Connected apps in Settings. A connection also ends when the authorizing user leaves the team.
Errors
The authorization and token endpoints return standard OAuth errors as JSON:{"error": "...", "error_description": "..."}.
On the REST API, an OAuth token that is expired, revoked, or unknown gets
401 with Unauthorized: Invalid or expired OAuth token. Refresh once, and if that fails with invalid_grant, ask the user to reconnect. A 503 with OAuth authentication is temporarily unavailable is temporary; retry with backoff. Other errors, such as 402 for insufficient credits, are the same as with an API key.
