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.
Twinr does not add a sign-in button to your app. Your website's own "Sign in with Google" button calls Twinr, which opens the native picker and hands the result back to you.
If you turn this on and expect a button to appear, nothing will happen. The website change in Step 4 is what makes it work.
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
| 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 | See Find your SHA-1 fingerprint. |
| Access to your website's code | Both the sign-in button and a server endpoint. |
Step 1: Turn it on
Open Integrations → 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.
| 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
- Open the console
Sign in to the Google Cloud Console.
- Create the project
Click New Project, enter a Project name such as
MyStore Sign-In, and click Create.
Configure the OAuth consent screen
This is the screen customers see when they pick an account.
- Open the consent screen settings
Go to APIs & Services → OAuth consent screen.

- Fill in your app information
Open Branding and complete App information.

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. - Finish and save
Add your Developer contact information, accept the Google API Services: User Data Policy, and click Save and Continue.
Using Firebase as well? Set a support email in Firebase Console → Project settings → General → Public settings → Support email too. Without it, sign-in fails.
Create the client IDs
Create one client per platform. For each, go to APIs & Services → Credentials → Create credentials → OAuth client ID.


- Set the application type
Choose iOS.
- Name the client
Enter a Name such as
MyStore iOS. It is only shown inside the console. - Enter your bundle ID
In Bundle ID, paste the iOS bundle ID copied from Twinr.
Leave App Store ID and Team ID empty.
- Create and copy
Click Create, then copy the 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.
- Set the application type
Choose Android.
- Name the client
Enter a Name such as
MyStore Android. - Enter your package name
In Package name, paste the Android package name copied from Twinr.
- 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.
- 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.
- Set the application type
Choose Web application.
- Name the client
Enter a Name such as
MyStore Web. - Leave the URL fields empty
Leave Authorized JavaScript origins and Authorized redirect URIs empty unless your website's own sign-in needs them.
- 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.
- Open App integrity
In Google Play Console, go to your app → Test and release → Setup → App integrity.
- Open the App signing tab
Select App signing.
- 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.
- 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. - your keystore file (
- Read the SHA-1 from the keystore
keytoolships with Java — if you have Android Studio, you already have it. Run:BASHkeytool -list -v -keystore path/to/your-keystore.jks -alias YOUR_KEY_ALIASReplace
YOUR_KEY_ALIASwith the Key Alias from the text file. When prompted for a password, use the Store Password. - Copy the fingerprint
Under Certificate fingerprints, copy the line beginning
SHA1:. It looks likeAB:CD:12:…— 20 pairs of characters.
Keep the keystore and Android key store information.txt private. Anyone holding both can sign apps as you.
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:
function handleGoogleSignIn() {
if (typeof twinr_google_sign_in === 'function') {
twinr_google_sign_in(); // inside the app: native account picker
} else {
runWebGoogleSignIn(); // in a browser: your existing Google 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:
POST /auth/google
Content-Type: application/json
Cookie: <the cookies your site set in the app>
{
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
"platform": "android",
"success": true,
"user_info": null
}
| 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:
{ "load_url": "https://your-domain.com/auth/google/complete?ticket=8f3c2a..." }
| 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.
You cannot sign the customer in from the webhook reply. The app calls your webhook directly, not through the page the customer is looking at, so a Set-Cookie header in the reply never reaches their session.
Instead, make load_url a one-time sign-in link. When the app opens it, your site checks the ticket, sets the session cookie, and redirects to the customer's account. Make each ticket single-use and expire it after a minute or two.
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. |
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.
https://your-domain.com/auth/google/callback?platform=ios&success=true&id_token=eyJhbGciOi...
- 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.
The token appears in the page address in this mode. After signing the customer in, redirect to a clean URL so it does not linger in their history or your server logs.
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.
window.onGoogleSignInResult = function (idToken) {
// signed in: show a loading state while your server finishes
};
window.onGoogleSignInCancelled = function () {
// the customer closed the account picker: reset the button
};
window.onGoogleSignInError = function (message) {
// sign-in failed: reset the button
console.error('Google Sign-In error:', message);
};
Handle the cancelled case. Customers often open the picker and change their minds, and a button left spinning looks broken.
Use these callbacks for the interface only. Do not sign the customer in from the idToken they receive — your server must verify it first. With URL redirect, the app leaves the page immediately, so the callbacks have little time to run.
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. |