Google sign-in for a game
Before you start
Section titled “Before you start”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.
In the Dashboard
Section titled “In the Dashboard”Choose an environment in the header, open Project settings → Authentication and add a Google connection.
| Field | Meaning |
|---|---|
Client ids | The client ids of your Google apps, comma separated: web, Android, iOS. A token issued for any other client id is refused. |
In the game
Section titled “In the game”The game signs in with Google Identity Services and sends the ID token it got.
TypeScript
Section titled “TypeScript”import { Session } from '@rudder/sdk';
const session = await Session.signIn(key, { provider: 'google', payload: { idToken },});C# and Unity
Section titled “C# and Unity”using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn{ Provider = "google", Payload = new Dictionary<string, object?> { ["idToken"] = idToken },});What the platform checks
Section titled “What the platform checks”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.
Errors
Section titled “Errors”- 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.