For the complete documentation index, see llms.txt. This page is also available as Markdown.

Google Sign-In

Let customers sign in with the Google account already on their phone, in one tap.

Google Sign-In lets customers sign in with the Google account already on their phone. They tap, pick an account, and they are in — no password to remember, no form to fill in on a small screen.

Inside the app it uses the phone's own native sign-in, so it looks and feels like every other app they use.

How it fits together

  1. A customer taps your site's Google sign-in button inside the app.

  2. Your page calls twinr_google_sign_in().

  3. The phone shows its native Google account picker.

  4. Google authenticates them and Twinr receives a token.

  5. Twinr sends that token to your Auth callback URL.

  6. Your server verifies it, signs the customer in, and tells the app which page to open.

Your server stays in charge of sessions throughout. Twinr delivers a verified token; what counts as being signed in remains yours.

What you will need

Requirement
Notes

A Google Cloud account

With admin access to the project.

Your iOS bundle ID and Android package name

Twinr shows both on the Google Sign-In screen, with a copy button.

Your Android SHA-1 certificate fingerprint

Access to your website's code

Both the sign-in button and a server endpoint.


Step 1: Turn it on

Open Native Features → Google Sign-In and switch on Enable Google Sign-In.

The Google Sign-In screen with its enable toggle

The settings below stay hidden until it is on.


Step 2: Choose how the token reaches you

Send token via offers two options.

Option
What happens

Webhook (POST JSON)

Twinr POSTs the token to your Auth callback URL as JSON.

URL redirect (query parameters)

The customer is redirected to your Redirect URL with the data in the query string.

Choose Webhook if your server verifies tokens before creating a session — it keeps the token off the customer's screen and out of their browser history. Choose URL redirect if your existing web sign-in already works that way.

Enter the matching URL. It must be HTTPS and publicly reachable.


Step 3: Create your Google OAuth client IDs

Google only signs a customer in when the request comes from an app it recognises. You tell Google about your app by creating OAuth client IDs in the Google Cloud Console — one per platform — then pasting them into Twinr.

Already use Google Sign-In on your website? Use that same Google Cloud project and skip ahead to Create the client IDs. Your web client ID is probably already there.

Create a Google Cloud project

1

Open the console

Sign in to the Google Cloud Console.

2

Create the project

Click New Project, enter a Project name such as MyStore Sign-In, and click Create.

This is the screen customers see when they pick an account.

1

Go to APIs & Services → OAuth consent screen.

The Google Cloud Console navigation menu with APIs & Services expanded and OAuth consent screen highlighted
2

Fill in your app information

Open Branding and complete App information.

The Branding page showing App name and User support email fields
Field
What to enter

App name

The name customers see on the consent screen.

User support email

An address customers can contact.

App logo

Optional. Uploading one requires verification unless the app is internal or in testing.

3

Finish and save

Add your Developer contact information, accept the Google API Services: User Data Policy, and click Save and Continue.

Create the client IDs

Create one client per platform. For each, go to APIs & Services → Credentials → Create credentials → OAuth client ID.

The Credentials page with the Create credentials menu open and OAuth client ID highlighted
The Create OAuth client ID form with Application type set to iOS and the Bundle ID field filled in
1

Set the application type

Choose iOS.

2

Name the client

Enter a Name such as MyStore iOS. It is only shown inside the console.

3

Enter your bundle ID

In Bundle ID, paste the iOS bundle ID copied from Twinr.

Leave App Store ID and Team ID empty.

4

Create and copy

Click Create, then copy the Client ID.

The Create OAuth client ID form with Application type set to Android, showing the Package name and SHA-1 certificate fingerprint fields

Google checks two things before it lets your Android app sign anyone in: the app's package name, and the SHA-1 fingerprint of the key that signed the build.

1

Set the application type

Choose Android.

2

Name the client

Enter a Name such as MyStore Android.

3

Enter your package name

In Package name, paste the Android package name copied from Twinr.

4

Enter the SHA-1 fingerprint

Enter the fingerprint of the key that signed the app customers install. Which key that is depends on how the app reaches them — see Find your SHA-1 fingerprint.

5

Create and copy

Click Create, then copy the Client ID.

Optional, but recommended. Your server uses it to check that a token really came from Google and was issued for your app.

1

Set the application type

Choose Web application.

2

Name the client

Enter a Name such as MyStore Web.

3

Leave the URL fields empty

Leave Authorized JavaScript origins and Authorized redirect URIs empty unless your website's own sign-in needs them.

4

Create and copy

Click Create, then copy the Client ID.

Find your SHA-1 fingerprint

Which fingerprint you need depends on how customers get the app.

With Play App Signing — the default for new apps — Google re-signs your app before customers download it. Use Google's key, not the one in Twinr.

1

Open App integrity

In Google Play Console, go to your app → Test and release → Setup → App integrity.

2

Open the App signing tab

Select App signing.

3

Copy the fingerprint

Under App signing key certificate, copy the SHA-1 certificate fingerprint.

For an APK you hand out yourself, or an internal test build, use the fingerprint of your Twinr keystore.

1

Download your keystore

In your app's dashboard, go to App Build → Android build. Under Build signing key, click Keystore. Two files download:

  • your keystore file (.jks)

  • Android key store information.txt, containing your Key Alias, Key Password and Store Password

If there is no Keystore button, your app has no signing key yet. Click Add, then either auto-generate a key or upload your existing .jks.

2

Read the SHA-1 from the keystore

keytool ships with Java — if you have Android Studio, you already have it. Run:

Replace YOUR_KEY_ALIAS with the Key Alias from the text file. When prompted for a password, use the Store Password.

3

Copy the fingerprint

Under Certificate fingerprints, copy the line beginning SHA1:. It looks like AB:CD:12:… — 20 pairs of characters.

Need both? If customers get the app from Google Play and you also test builds signed by Twinr, create two Android clients with the same package name — one per fingerprint. Put the Google Play one in Twinr.

Paste the IDs into Twinr

Back on the Google Sign-In screen, fill in Google OAuth client IDs.

Twinr field
Paste

Web client ID (optional)

The Web application client ID

iOS client ID

The iOS client ID

Android client ID

Your production Android client ID

Every client ID ends in .apps.googleusercontent.com.

Click Save as draft.

Google Sign-In does not use the Firebase config files. google-services.json and GoogleService-Info.plist are for push notifications and Firebase Analytics — see Firebase Setup. Google Sign-In needs the three OAuth client IDs above, and nothing else.

Both come from Google, which is why they are easily confused. Uploading a config file will not switch Google Sign-In on, and these client IDs will not enable push.


Step 4: Connect your website

Your website needs two changes: your sign-in button calls Twinr, and your server handles the token Twinr sends back.

Why not use your existing Google sign-in? Google blocks its sign-in page inside apps that show websites (Error 403: disallowed_useragent). Inside the app, the phone's native picker is the only way in — which is why your button has to call Twinr.

Call Twinr from your sign-in button

When Google Sign-In is enabled, the app adds twinr_google_sign_in() to every page it opens. It exists only inside your app with this feature on — not in a normal browser. Check for it, and fall back to your usual web sign-in:

Wire your existing Google button to handleGoogleSignIn().

Receive the token by webhook

With Send token via set to Webhook (POST JSON), the app sends a POST to your Auth callback URL after every attempt:

Field
What it holds

id_token

The Google ID token (a JWT). null when success is false.

platform

ios or android.

success

true when the customer signed in and Google returned a token.

user_info

A username or buyer ID the app already knows for this customer, if any. Usually null — identify the customer from the token, not this.

error_message

Sent only when success is false. cancelled means the customer closed the picker; anything else is the failure reason.

The Cookie header carries your site's cookies from the app, so you can match the sign-in to an existing visitor — a guest cart, for example.

Reply with HTTP 200 and the page to open:

Your reply
What the customer sees

200 with load_url

The app opens load_url.

200 without load_url

Nothing changes. The page stays where it was.

Any other status, or no response

A Sign In Failed message.

When sign-in fails on the phone, the app still calls your webhook with success: false and shows Sign In Failed itself. If the customer cancelled, it shows nothing. Reply 200 to these calls.

Verify the token on your server

Never sign anyone in from a token you have not verified. Use Google's library for your language — it checks the signature, issuer and expiry for you.

Check
What to do

Audience (aud)

Accept the client IDs you entered in Twinr. With a Web client ID set, tokens from both platforms carry that ID; without one, iPhone tokens carry your iOS client ID.

Customer ID

Identify the customer by the token's sub field. An email address can change; sub never does.

Email

Trust email only when email_verified is true.

Receive the token by URL redirect

With Send token via set to URL redirect (query parameters), the app opens your Redirect URL with the result in the query string. Any parameters already in your URL are kept.

  • On success — success=true and id_token are present. Verify the token as above, then set the session cookie in your response. The page opens in the app's browser, so cookies work here.

  • On cancel or failure — success=false and no id_token. The reason is not sent in this mode. Show your sign-in page again.

Optional page callbacks

The app tells the page that called twinr_google_sign_in() how the attempt ended, so you can update the button. These run before the token is sent to your server.

Handle the cancelled case. Customers often open the picker and change their minds, and a button left spinning looks broken.


Troubleshooting

Problem
Where to look

Nothing happens when the button is tapped

twinr_google_sign_in is undefined. Check that Google Sign-In is enabled, that the installed app is a build made after you enabled it, and that your button calls handleGoogleSignIn().

The account picker does not appear on Android

Most often the SHA-1 on your Android OAuth client does not match the key that signed this build. Builds from Google Play use the Play app signing key; builds signed by Twinr use your Twinr keystore. Also check the device has Google Play Services and a Google account signed in.

Authentication fails

A client ID in Twinr does not match Google Cloud Console, or the bundle ID or package name there differs from the one Twinr shows.

Sign In Failed appears after picking an account

Your webhook did not reply with HTTP 200. Check it received the POST and did not reject the token — a wrong aud in your verification is the usual cause.

Your server signs the customer in, but the app still shows them signed out

You set the session cookie in the webhook reply, which the app never sees. Return a one-time sign-in link as load_url instead.

Your callback is never called

The URL must be HTTPS, publicly reachable, and must match the Send token via option you chose.

Works in a browser, not in the app

The installed app predates the feature. Customers need a build made after you enabled it.

Last updated