Skip to content

Facebook login for games

A Facebook app in the Meta developer portal, with the platforms of the game enabled and the Facebook Login product added. The app id is public; the app secret is shown in the settings of the app.

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

FieldMeaning
App idThe id of your Facebook app.
SecretThe app secret. Paste the one from the Facebook dashboard; a generated one will not be accepted by Facebook.

The game sends the access token the Facebook SDK gave it.

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

The platform asks the Graph API about the token, with the app id and the secret, and accepts it only when Facebook says it is valid and belongs to your app. The player is the Facebook user id of the app.

Facebook returns no nickname or picture in this answer, so the game fills those.

  • A token of another app, an expired one, or one Facebook rejects answers 401 unauthorized.
  • The Graph API not answering answers 503 try_again.

The rest are in Errors.