Skip to content
Random game

Know the player

Last updated 2026-11-19

Every player on FreeGames.gg has a Foony account. When a signed-in player opens your game, init() gives your game a player token. Your server trades it for a player id that stays the same on every visit and every device. Your game needs no login screen, and never sees a password or the player’s Foony session.

How it works

  1. Your game calls init() and gets playerToken.
  2. Your game sends the token to your own server.
  3. Your server sends it to Foony’s game server and gets back {playerId, gameId, expiresAt}.
  4. Your server keeps the player’s data under playerId.
// In your game.
const {playerToken} = await sdk.init();
if (playerToken) {
  await fetch('https://api.example.com/session', {
    method: 'POST',
    headers: {'content-type': 'application/json'},
    body: JSON.stringify({playerToken}),
  });
}
// On your server (Node 18 or newer, Express).
app.post('/session', async (request, response) => {
  const answer = await fetch('https://s2.foony.com/portal-auth/verify-player', {
    method: 'POST',
    headers: {'content-type': 'application/json'},
    body: JSON.stringify({playerToken: request.body.playerToken}),
  });
  if (!answer.ok) {
    response.status(401).json({error: 'bad player token'});
    return;
  }
  const {playerId, gameId} = await answer.json();
  if (gameId !== MY_GAME_ID) {
    response.status(401).json({error: 'token for another game'});
    return;
  }
  response.json({sessionId: await startSession(playerId)});
});

Your server’s host must be approved for your game (see external_requests in the requirements), and it must allow requests from your game’s build address (CORS).

What you get back

Field Meaning
playerId The same text for one player in your game, on every visit and every device. Another game gets a different id for the same player, so games can’t match players up
gameId The game the token was made for. Check it is yours
expiresAt When the token stops working, in milliseconds since 1970

That is all. No Foony account id, no name, no email, no friends list, no age. This is the same for every player, players under 13 included.

Guests get no token

playerToken is null for a player who hasn’t signed in. Guests play every game the same way. Keep their progress with saves, or give them a guest id of your own on your server.

Limits

  • A token lasts 5 minutes from init(). Check it once when the game starts, then use your own session.
  • One token is made per page load. There is no call for a new one.
  • The check route allows about 50 checks a second from one server address. Over that, it answers 429.

Errors

Answer Meaning
400 {"error": "invalid_player_token"} The token is wrong, changed, too old, or wasn’t made by FreeGames.gg
429 {"error": "rate_limited"} Too many checks from your server’s address. Wait a second and try again

What the token is not

  • It is not a login. It gives no access to the player’s Foony account, coins, friends or other games.
  • It is not a secret to keep for later. It stops working after 5 minutes. Keep playerId, not the token.