Facebook login for games
Before you start
Section titled “Before you start”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.
In the Dashboard
Section titled “In the Dashboard”Choose an environment in the header, open Project settings → Authentication and add a Facebook connection.
| Field | Meaning |
|---|---|
App id | The id of your Facebook app. |
Secret | The app secret. Paste the one from the Facebook dashboard; a generated one will not be accepted by Facebook. |
In the game
Section titled “In the game”The game sends the access token the Facebook SDK gave it.
TypeScript
Section titled “TypeScript”import { Session } from '@rudder/sdk';
const session = await Session.signIn(key, { provider: 'facebook', payload: { accessToken },});C# and Unity
Section titled “C# and Unity”using RudderSdk;
var session = await Session.SignInAsync(key, new ProviderSignIn{ Provider = "facebook", Payload = new Dictionary<string, object?> { ["accessToken"] = accessToken },});What the platform checks
Section titled “What the platform checks”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.
Errors
Section titled “Errors”- 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.