CrazyGames sign-in for HTML5 games
Before you start
Section titled “Before you start”A game published on CrazyGames, and its game id from the developer portal. The account of a
player exists only inside crazygames.com: a game embedded anywhere else gets no token, and
window.CrazyGames.SDK.user.isUserAccountAvailable says so before the sign-in is tried.
In the Dashboard
Section titled “In the Dashboard”Choose an environment in the header, open Project settings → Authentication and add a CrazyGames connection.
| Field | Meaning |
|---|---|
Game id | The id of your game on CrazyGames. A token of another game is refused. |
In the game
Section titled “In the game”Inside the CrazyGames page the game asks their SDK for the user token and sends it.
TypeScript
Section titled “TypeScript”import { Session } from '@rudder/sdk';
const token = await window.CrazyGames.SDK.user.getUserToken({ signingKeyType: 'IN_GAME_AUTH' });
const session = await Session.signIn(key, { provider: 'crazygames', payload: { idToken: token },});C# and Unity
Section titled “C# and Unity”A WebGL build reaches the SDK of CrazyGames through a JavaScript bridge, and the same token goes into the same payload:
using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn{ Provider = "crazygames", Payload = new Dictionary<string, object?> { ["idToken"] = tokenFromTheBridge },});A native build has no bridge to that SDK and no page of crazygames.com around it, so it cannot
sign in this way.
What the platform checks
Section titled “What the platform checks”The signature against the published keys of CrazyGames, the expiry, and that the token names your
game id. The player is the userId of the token; its username and profilePictureUrl fill a
nickname and an avatar the player does not have yet.
Errors
Section titled “Errors”- A token of another game, or one that is expired or foreign, answers
401 unauthorized. - CrazyGames not answering its keys answers
503 try_again.
The rest are in Errors.