Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io

    Google, Apple & Facebook Sign-In

    Two paths, and the shorter one is usually right

    Where the provider ships a browser or platform SDK, let it obtain the token and hand that to BillDog — an ID token for Google and Apple, an access token for Facebook, each with its own method because each is verified differently. Where there is no provider SDK — or where you would rather the exchange happened server-side — use the redirect flow, which runs PKCE with the verifier never leaving our server.

    Which providers

    PathProvidersUse when
    signInWithIdTokenGoogle, AppleYou already have an ID token from the provider's SDK
    signInWithAccessTokenFacebook onlyYou already have an access token from Facebook's JS SDK
    signInWithRedirectGoogle, Apple, FacebookNo provider SDK, or you want the exchange server-side. This is the path a hosted wall uses

    Facebook has its own method, and it is not the ID-token one. Facebook’s ordinary (“classic”) login flow returns an access token and no ID token, so there is no provider signature for signInWithIdToken to verify. An access token is checked a different way — by asking Facebook which application it was issued to — and the server picks which check to run off the field name in the body. So the two are separate calls, and signInWithIdToken does not accept 'facebook' at all: it is excluded from the provider type, and sending a Facebook request with id_token is answered 400 (“facebook requires access_token”).

    If your app already links the Facebook SDK and you would rather keep using it, pass the access token it gives you to signInWithAccessToken. If it does not, signInWithRedirect runs the whole flow for you, which means a Facebook button needs no Facebook SDK in your app, on any platform.

    Code
    // Facebook's JS SDK (FB.login) gives you an ACCESS token.
    const result = await auth.signInWithAccessToken({
      provider: 'facebook',
      accessToken,
    });
    
    // Same three-state answer as attempt(): read this BEFORE result.session.
    if (result.mfaRequired) { /* see "A second factor after a social sign-in" */ }
    else { use(result.session); }

    The token is not merely decoded. BillDog calls Facebook’s debug_token and refuses the sign-in unless the application the token was issued to is yours — that app-id comparison is the audience check, and without it any Facebook app’s token would sign anyone in. It needs your app secret, which is why the exchange is refused outright rather than accepted unverified when one is not configured.

    Path 1 — the provider's SDK

    Code
    // Google Identity Services / Sign in with Apple JS give you an ID token.
    const result = await auth.signInWithIdToken({
      provider: 'google',   // or 'apple' — never 'facebook'
      idToken,
    });
    
    // Same three-state answer as attempt(): read this BEFORE result.session.
    if (result.mfaRequired) { /* see "A second factor after a social sign-in" */ }
    else { use(result.session); }

    BillDog verifies the provider's signature over its own claims and checks the audience against the client IDs configured for your project. No client secret is involved and no redirect happens, which is why this reaches a proven session in one call. Facebook takes the same path through signInWithAccessToken, shown above — the method differs because the check does, not because the flow does.

    Ask config() which providers the project has configured before you render a button. It returns oauthProviders keyed by provider — Google's and Apple's client IDs, Facebook's app ID — and an absent entry means no credential, so the exchange would be refused. A button you cannot complete is worse than one you never showed.

    Path 2 — the redirect flow

    Code
    // Navigates away to the provider.
    await auth.signInWithRedirect({
      provider: 'google',
      redirectUri: 'https://app.example.com/auth/callback',
    });
    
    // On your callback page:
    const result = await auth.completeRedirectSignIn();
    // null when the URL carries no ?code — safe to call unconditionally.
    if (result?.mfaRequired) { /* a second factor is owed; see below */ }
    else if (result) { use(result.session); }

    Apple on the web: the signing key

    Apple is the one provider that issues no client secret. Its token endpoint wants a short-lived assertion you sign with the private key from your developer account, so a web or Android Apple sign-in — and every "Continue with Apple" button on a hosted wall — needs three things beyond the Services ID, all under Project Settings → OAuth → Apple:

    • Team ID — ten characters, from Membership in the developer portal.
    • Key ID — ten characters, shown next to the Sign in with Apple key you created (it is also in the file name, AuthKey_KEYID.p8).
    • Private key (.p8) — the whole file as downloaded. It is stored encrypted, never shown again, and used only on the server to sign a five-minute client secret at each exchange. Leave the field blank on a later save to keep the stored key.

    Then register the Return URL the tab shows you, exactly, under the Services ID’s Website URLs → Return URLs. It is BillDog’s auth-oauth-bounce endpoint, the same for every project — not your page and not your wall. Apple returns the authorization as a form POST whenever name or email is requested, and a sign-in page is served on GET only, so Apple posts to the bounce and the bounce sends the visitor on to where the flow began with a 303. The ID token and the one-time name/email payload never travel in that redirect; the callback re-obtains and verifies the token at the exchange.

    Native iOS needs none of this — the platform supplies the flow and the SDK sends the resulting token to signInWithIdToken. An Apple project without the three signer fields is refused at auth-oauth-start with a message naming them ("needs the Team ID, Key ID and .p8 private key"), before anyone is walked through Apple's consent screen.

    A second factor after a social sign-in

    A social sign-in ends the same two ways a password does. Against an account enrolled in a second factor, the provider accepts the person and BillDog answers with a challenge instead of a session — exactly what attempt does for a correct password. The completion call is the same one, minus the identifier: there is none in a social sign-in, and the mfaToken already names the account.

    const result = await auth.signInWithIdToken({ provider: 'google', idToken });
    // or: const result = await auth.completeRedirectSignIn();
    
    if (result.mfaRequired) {
      const done = await auth.attempt({
        strategy: 'totp',          // or 'backup_code'
        code: authenticatorCode,
        mfaToken: result.mfaToken, // no identifier — the token names the account
      });
      use(done.session);
    } else {
      use(result.session);
    }

    On a hosted wall there is nothing to write: the Auth Card notices the challenge when the browser returns from the provider and shows the code step itself, with no identifier field, under "Finish signing in with your authentication code."

    Setting up the providers

    Project Settings → OAuth. Both paths read the same configuration, so you set a provider up once regardless of which you use. For Google you need the client IDs from Google Cloud Console — iOS, Android and web often differ, and all of them are checked as valid audiences — plus the Web Client Secret if you use the redirect path, because Google refuses the code exchange for a web client without one. The secret is stored encrypted and never reaches a client. Facebook needs its App ID and its App Secret from the Meta Developer Console; the secret is required for every Facebook path, not only the redirect one. Apple needs the bundle ID for iOS apps, and the Services ID plus the Team ID, Key ID and .p8 key described above for everything else. The tab configures all three providers.

    An unconfigured provider fails with a message saying so. On a hosted sign-in wall the provider buttons are toggles on the Auth Card — Google, Apple and Facebook — and turning one on without configuring the provider is the most common cause of a button that reports an error on tap.

    Account linking

    Both paths resolve to the same identity, so a person who signed up with a password and later uses Google with the same verified address arrives at the same user rather than a duplicate. Verification is what makes that safe: linking on an unverified address would let anyone who can assert an email address inherit the account that already owns it.

    Native apps

    iOS and Android handle the provider ceremony natively and hand the resulting token to the SDK. On iOS, Sign in with Apple is a platform requirement if you offer any other social sign-in — Apple's App Review guideline 4.8, not ours. Facebook on either platform, Google on iOS and Apple on Android run BillDog's redirect flow in a browser the SDK opens and closes itself; the provider returns to the bounce, and the bounce forwards to the app's own billdog:// URI. An iOS app that would rather run Google's own SDK can opt in with OAuthManager.shared.preferHostGoogleSDK.

    Next

    Was this page helpful?

    Or rate this page:

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.