Skip to content

Google sign-in for a game

An OAuth 2.0 client id from the Google Cloud Console. A web client needs the address of the game among its authorized JavaScript origins. An Android client needs its package name and the SHA-1 of the signing key; an iOS client needs its bundle id. The game page loads the script of Google Identity Services from accounts.google.com.

Choose an environment in the header, open Project settings → Authentication and add a Google connection.

FieldMeaning
Client idsThe client ids of your Google apps, comma separated: web, Android, iOS. A token issued for any other client id is refused.

The game signs in with Google Identity Services and sends the ID token it got.

import { Session } from '@rudder/sdk';
const session = await Session.signIn(key, {
provider: 'google',
payload: { idToken },
});
using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn
{
Provider = "google",
Payload = new Dictionary<string, object?> { ["idToken"] = idToken },
});

The signature against the published keys of Google, the issuer accounts.google.com, the audience against your client ids, and the expiry. The player is the sub of the token. The name and the picture of the account fill a nickname and an avatar that the player does not have yet.

  • An expired token, another client id or another issuer answers 401 unauthorized.
  • Google not answering its keys answers 503 try_again.

The rest are in Errors.