v1 · OpenAPI 3.1Dashboard

Users and sign-in

Sign in with Google

Users can sign in with their Google account. Fox Login handles the Google side with its own Google app: your app sends the browser to a Fox Login URL, the user picks an account at Google, and Fox Login sends the browser back to your redirect URL with a one-time code. You exchange that code for the same session the other sign-in methods return.

1. Turn it on and add redirect URLs

In the dashboard, open the application and go to Login settings > Google.

  1. Check that the Google switch is on. It is on for every new application.
  2. Under Redirect URLs, add each address users should come back to, such as https://anka.io/auth/callback, plus http://localhost:3000/auth/callback while you develop, and save.

The provider card shows Ready once the application has at least one redirect URL.

The same card shows a Return URL, https://<region>.auth.foxlogin.app/v1/oauth/google/callback. Google sends users back to that address, and Fox Login then forwards them to your redirect URL. Fox Login manages it as part of its own Google app, so you do not enter it in the Google Cloud console or anywhere else. Users see "Fox Login" on Google's account chooser.

Using your own Google app, so that Google shows your app's name, is planned. Until then there is nothing to set up at Google.

Redirect URLs follow these rules:

Rule Value
Scheme https. http works only for localhost, 127.0.0.1 and [::1].
Matching Exact: scheme, host, port, path and query must match character for character. There are no wildcards.
Format A host, no user name or password, no #, * or spaces, at most 500 characters.
Number Up to 20 per application.

Your backend can set the same list with PATCH /applications/{app_id}, described in Management API.

2. Send the user to Google

Build the start URL on the sign-in host of the application's region, the same host the SDK uses: a pk_live_eu_… key means eu.auth.foxlogin.app, a pk_live_tr_… key tr.auth.foxlogin.app. Open it as a page with a link or location.assign; a fetch call cannot show Google's screens.

Browser
const state = crypto.randomUUID();
sessionStorage.setItem("fox_state", state);

const start = new URL("https://eu.auth.foxlogin.app/v1/oauth/google/start");
start.searchParams.set("publishable_key", "pk_live_eu_…");
start.searchParams.set("redirect_uri", "https://anka.io/auth/callback");
start.searchParams.set("state", state);

location.assign(start);
Parameter Meaning
publishable_key Required. The application's publishable key. It goes in the URL because a page load cannot send the X-Fox-Publishable-Key header.
redirect_uri Required. One of the application's redirect URLs, exactly as saved.
state Optional, up to 512 characters. Fox Login returns it unchanged. Use a random value and compare it when the user comes back.
country Optional. An ISO 3166-1 alpha-2 code for new users. With it, Fox Login creates a new user right away; without it, you ask for the country in step 3. Existing users keep their country.

When the start URL itself is wrong, Fox Login shows a JSON error instead of redirecting: 400 redirect_uri_not_allowed when redirect_uri is not on the list, 422 provider_disabled when Google sign-in is off, 400 invalid_state, 400 invalid_country or 422 country_not_allowed. Each IP address can start 30 Google sign-ins per minute.

3. Handle the return

Fox Login sends the browser to your redirect URL with one of three results in the query string, plus your state:

Query Meaning Next step
fox_code The Google account belongs to a user of the application, or Fox Login created one with the country you passed. POST /v1/client/oauth/token within 2 minutes.
fox_status=country_required and fox_ticket A new user, and the start URL had no country. Ask for the country, then POST /v1/client/oauth/complete within 15 minutes.
fox_error The sign-in did not finish. Show a message and let the user try again.

Both POST endpoints take the X-Fox-Publishable-Key header and answer like a password sign-in: a session, or mfa_required when the user has two-factor authentication on.

Browser
const q = new URLSearchParams(location.search);
history.replaceState(null, "", location.pathname); // the code works once
if (q.get("state") !== sessionStorage.getItem("fox_state")) throw new Error("state mismatch");
sessionStorage.removeItem("fox_state");

const api = "https://eu.auth.foxlogin.app/v1/client/oauth";
const headers = { "content-type": "application/json", "x-fox-publishable-key": "pk_live_eu_…" };

async function call(path: string, body: object) {
  const res = await fetch(`${api}/${path}`, { method: "POST", headers, body: JSON.stringify(body) });
  const data = await res.json();
  if (!res.ok) throw new Error(data.error.code);
  return data;
}

let result;
if (q.has("fox_code")) {
  result = await call("token", { code: q.get("fox_code") });
} else if (q.get("fox_status") === "country_required") {
  const country = await askForCountry(); // for example "TR"
  result = await call("complete", { ticket: q.get("fox_ticket"), country });
} else {
  showError(q.get("fox_error"));
}

if (result?.status === "mfa_required") askForTotpCode(result.mfa_token);
else if (result) keepSession(result); // { user, session_id, access_token, refresh_token, token_type, expires_in }

The code works once, for 2 minutes, and only with the publishable key of the application that started the sign-in. A used or expired code returns 400 invalid_code; send the user back to step 2.

The session has the same fields as from the client endpoints. The SDK cannot take it over yet, so keep the tokens yourself: refresh them with POST /v1/client/token and end the session with POST /v1/client/sign_out.

New users and the country

Only a user Fox Login has not seen before gets fox_status=country_required. Show a country picker and send the ISO 3166-1 alpha-2 code with the ticket. If the application accepts only listed countries, any other country gets 422 country_not_allowed. The ticket stays valid, so the user can pick again. A wrong, used or expired ticket returns 400 invalid_code.

If your page already knows the country, pass country in the start URL and this step never comes up.

fox_error values

fox_error Meaning
access_denied The user cancelled on Google's screen.
provider_error Fox Login could not use Google's answer. Let the user try again.
email_not_verified Google has not verified the email address of this Google account.
account_locked The user this Google account belongs to is not active.
country_not_allowed The application does not accept the country from the start URL.
server_error Fox Login could not finish the sign-in. Let the user try again.

Treat any other value like provider_error.

Each sign-in can come back from Google once, within 10 minutes. If the user takes longer, or opens the same return link twice, Fox Login shows its own "This sign-in link has expired" page instead of redirecting. The user goes back to your app and starts again.

Existing users and linking

Users belong to one application, so the same Google account is a separate user in each of your applications.

The first time a Google account signs in to an application, Fox Login looks for a user with the same email. Google must have verified that address. If such a user exists, Fox Login links the Google account to it, marks the user's email as verified and records an identity.linked event. That user can then sign in with Google as well as with their password or an email code. If there is no such user, Fox Login creates one with the email and name from Google and email_verified: true, and records user.created with method: "google".

Later sign-ins follow the link, so they reach the same user even if the address at Google changes. Every Google sign-in records user.signed_in with method: "google". Both events are in the event log.

Two-factor authentication

A user with TOTP on still needs the second factor after Google. In that case the token and complete calls answer { "status": "mfa_required", "mfa_token": "…" } instead of a session. Pass the token to the SDK's verifyMfa, which finishes the sign-in and keeps the session, or call POST /v1/client/sign_in/mfa yourself. Two-factor authentication covers the codes and errors.

Endpoints

HTTP Purpose Success
GET /v1/oauth/google/start Send the browser to Google 303 redirect to Google
POST /v1/client/oauth/token Exchange fox_code for a session 200 session or mfa_required
POST /v1/client/oauth/complete Create a new user with a country and sign in 200 session or mfa_required

The two POST endpoints count toward the limit of 20 code checks per minute per IP address. The API reference has the full request and response schemas.