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
A customer taps your site's Google sign-in button inside the app.
Your page calls
twinr_google_sign_in().The phone shows its native Google account picker.
Google authenticates them and Twinr receives a token.
Twinr sends that token to your Auth callback URL.
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
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 settings below stay hidden until it is on.
Step 2: Choose how the token reaches you
Send token via offers two options.
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.
Create a Google Cloud project
Open the console
Sign in to the Google Cloud Console.
Configure the OAuth consent screen
This is the screen customers see when they pick an account.
Create the client IDs
Create one client per platform. For each, go to APIs & Services → Credentials → Create credentials → OAuth client ID.


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.
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.
Optional, but recommended. Your server uses it to check that a token really came from Google and was issued for your app.
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.
For an APK you hand out yourself, or an internal test build, use the fingerprint of your Twinr keystore.
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.
Paste the IDs into Twinr
Back on the Google Sign-In screen, fill in Google OAuth client IDs.
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.
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.
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:
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:
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.
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.
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=trueandid_tokenare 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=falseand noid_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
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


