Authentication

Google sign-in

Create an OAuth client in the Google Cloud Console, paste its credentials into CubiBase, and register the callback URL. Two flows: browser redirect, or a Google ID token your app already holds.

Configure it step by step

Everything happens in two places: console.cloud.google.com for the Google side, and Console → project → Auth → Providers → Google for the CubiBase side.

  1. Google: select or create a project

    Open console.cloud.google.com and pick the Google Cloud project for your app.

  2. Google: configure the OAuth consent screen

    APIs & Services → OAuth consent screen. Choose External, fill in the app name and the support and developer contact emails, and add the scopes openid, email, and profile. While the app is in Testing, only listed test users can sign in; publish to production when you are ready for everyone.

  3. Google: create an OAuth client

    APIs & Services → Credentials → Create credentials → OAuth client ID → Web application.

  4. Google: register the redirect URI

    Copy the Authorized redirect URI that the CubiBase Google section displays — it looks like https://{slug}.api.cubibase.com/auth/v1/callback?provider=google&project={projectId}. Paste it exactly, query parameters included.

  5. CubiBase: enable the provider

    In Auth → Providers → Google, tick Enable Google sign-in, paste the Client ID and Client secret, and save. The secret is stored encrypted and never shown again; the section shows a Secret stored badge instead.

  6. CubiBase: allowlist your app’s URLs

    In the same form, fill the App redirect allowlist with the URLs in your app that should receive the session — one per line; a trailing * allows prefix matches. Loopback HTTP redirect URLs are always allowed for native and local development.

The browser redirect flow

  1. Your app

    asks for a consent url

  2. CubiBase Auth

    single-use state

  3. Google

    user consents

  4. CubiBase callback

    verifies code + state

Illustration. The session rides in the URL fragment, which browsers never send to servers.

Your app starts the flow with GET /auth/v1/authorize?provider=google&redirect_to={your callback URL}, sending the publishable key. The response contains a url: send the browser there.

1 · Start the flow
GET https://example-project.api.cubibase.com/auth/v1/authorize?provider=google&redirect_to=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback
apikey: cb_pub_EXAMPLE_ONLY
2 · Response: open this url
{
  "url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=…&redirect_uri=…&response_type=code&scope=openid%20email%20profile&state=…",
  "state": "<SINGLE_USE_STATE>",
  "expiresAt": "2026-11-20T10:10:00.000Z"
}

Google shows its consent screen and redirects back to the CubiBase callback, which verifies the response and redirects the browser to your redirect_to with the session in the URL fragment (the part after #).

3 · Your callback page reads the fragment
https://app.example.com/auth/callback#access_token=<ACCESS_JWT>&refresh_token=<REFRESH_TOKEN>&token_type=Bearer&expires_in=3600&expires_at=2026-11-20T11%3A00%3A00.000Z

The ID-token flow (mobile and web SDKs)

If your app already obtains a Google ID token — Google Sign-In on Android, iOS, or the web — skip the redirect flow and POST it to /auth/v1/token?grant_type=id_token with the publishable key.

Verify a Google ID token
POST https://example-project.api.cubibase.com/auth/v1/token?grant_type=id_token
apikey: cb_pub_EXAMPLE_ONLY
Content-Type: application/json

{
  "provider": "google",
  "idToken": "<GOOGLE_ID_TOKEN>"
}

CubiBase verifies the token’s RS256 signature against Google’s published keys, the issuer, the audience (your Client ID), and the expiry, then returns a normal session. Pass a nonce to bind the token to your sign-in attempt.

Identity rules (both flows)

SituationWhat happens
Google account has signed in beforeSigns straight in
Request carries an end-user bearer tokenThe Google identity links to that user — the anonymous upgrade path
Verified Google email matches an existing userThe identity attaches to that account
New Google accountSigns up a new user (the signup switch applies)
User has a verified factor, project requires MFA403 mfa_required — Google alone does not satisfy MFA

Additional resources