Entra ID authentication is an alternative to developer secret keys for Admin, Server and some entity API calls. Player-facing Client and entity APIs continue to use session tickets and entity tokens obtained through player sign-in. Only entity APIs that are callable with a title entity token can be used with Entra ID. For more information about secret keys, see Secret key management.
Why use Entra ID authentication
Developer secret keys are simple to use, but Entra ID authentication offers several advantages:- No shared secrets—Public client flows don’t require a client secret. Tokens are short-lived and scoped to the signed-in user.
- Individual accountability—Each API call is tied to a specific user identity, making it easy to audit who did what.
- Conditional access—Your organization can apply Entra ID policies like IP restrictions, multifactor authentication (MFA), and device compliance checks.
How Entra ID authentication works
If you’ve never worked with Microsoft Entra ID before, it’s Microsoft’s cloud identity service—the same identity system that backs Microsoft 365, XBOX developer accounts, and Azure. Instead of PlayFab issuing your studio a long-lived secret key, your tool asks Entra ID to sign in a developer and hand back a short-lived access token. PlayFab trusts tokens that Entra ID issues for users who are members of your studio. Three parties are involved:- The developer. You, signed in with a Microsoft Account (personal) or a work or school account (Entra ID).
- An app registration in Entra ID. This represents the tool that calls PlayFab—a CLI, a build script, an internal dashboard, and so on. It tells Entra ID “this app is allowed to ask for PlayFab access tokens on behalf of a signed-in user.”
- The PlayFab service. PlayFab is registered in Entra ID under the application ID
448adbda-b8d8-4f33-a1b0-ac58cf44d4c1and exposes a delegated permission calledplugin. When your code requests the scope448adbda-b8d8-4f33-a1b0-ac58cf44d4c1/plugin, Entra ID issues a token that PlayFab accepts.
- Your code uses the Microsoft Authentication Library (MSAL) to start a sign-in—usually a browser pop-up or a device code prompt.
- The user signs in with their Microsoft identity and consents to your app calling PlayFab on their behalf.
- MSAL returns an access token (a JWT) and caches a refresh token so future calls can skip the prompt.
- Your code sends the token in the
Authorization: Bearer <token>header on each PlayFab request. - PlayFab validates the token, maps it to the matching studio user, and authorizes the call based on that user’s role.
Prerequisites
- A Microsoft account backed by Entra ID (a work or school account) or a personal Microsoft account (MSA).
- A PlayFab title. For more information, see Create a PlayFab account.
- Permissions to register applications in your Microsoft Entra ID tenant.
- The calling user must be added to the PlayFab studio and assigned as a title admin. For more information about roles, see PlayFab user roles.
Register a public client application in Entra ID
You need to register an application in your Entra ID tenant so your code can request delegated tokens on behalf of a signed-in user. For public client flows (SPA, device code, implicit), no client secret is needed.- Sign in to the Azure portal.
- Search for and select App registrations, then select New registration.
-
Enter a name for your application (for example,
PlayFab API Client). - Under Supported account types, select the option that matches your organization’s requirements. For maximum flexibility, select Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts. This option allows any Microsoft account to authenticate.
-
Configure the Redirect URI based on your application type:
- For a single-page application (SPA), select Single-page application (SPA) and enter your redirect URI (for example,
http://localhost:3000). - For a native or console application using device code flow, select Public client/native (mobile & desktop) and enter
http://localhost.
- For a single-page application (SPA), select Single-page application (SPA) and enter your redirect URI (for example,
- Select Register. On the overview page, note the Application (client) ID. You need this value when requesting tokens.
-
Add the PlayFab API permission to your app registration:
- In the Azure portal, navigate to your app registration and select API permissions.
- Select Add a permission > APIs my organization uses.
- Search for the PlayFab application ID
448adbda-b8d8-4f33-a1b0-ac58cf44d4c1and select it. - Select Delegated permissions, check the plugin permission, and select Add permissions.
If your scenario requires a confidential (web app) client, you also need to create a client secret under Certificates & secrets. This article focuses on public client flows, which don’t require a secret. For more information about confidential client flows, see Microsoft identity platform and OAuth 2.0 authorization code flow.
Set up PlayFab studio access
PlayFab validates Entra ID tokens against studio membership. The calling user must be added to the PlayFab studio and granted the appropriate role.- Have a studio admin sign in to Game Manager.
- Navigate to the studio’s Users section.
- Select Add User and enter the Microsoft account email of the developer who needs API access.
- Select Microsoft as the authentication provider.
- Assign the user a role that includes Admin or Server API access. At minimum, the user must be a title admin for the titles they need to call APIs against.
- Select Add user to send the invitation.
Obtain an access token
Your application is responsible for signing in the user and obtaining a delegated access token from Entra ID. The following examples show common public client flows.Interactive browser flow (recommended for desktop and console apps)
Interactive browser flow opens a system browser window for sign-in. It’s the recommended option for desktop applications and local development tools.Authorization code with PKCE (recommended for SPAs)
Authorization code flow with Proof Key for Code Exchange (PKCE) is the recommended approach for single-page applications. The following JavaScript example uses the Microsoft Authentication Library (MSAL):Call PlayFab APIs with the access token
Include the Entra ID access token in theAuthorization header as a Bearer token in your PlayFab API requests, instead of using the X-SecretKey header.
Example request
You can’t use both
X-SecretKey and Authorization: Bearer in the same request. Use one authentication method per call.C# example
The following example uses the Microsoft Authentication Library (MSAL) to obtain a token and calls theServer/GetTime API. Replace your-client-id with the Application (client) ID from your app registration.
Node.js example
The following example uses the@azure/msal-node library to obtain a token and calls the Server/GetTime API. Replace your-client-id with the Application (client) ID from your app registration.
Token refresh
Entra ID access tokens are short-lived (typically 60–90 minutes). If you’re using MSAL, callAcquireTokenSilent (C#) or check the token cache before each request—MSAL handles refresh automatically when a cached refresh token is available.
If you’re managing tokens manually, request a new token using the same sign-in flow before the current one expires.
If a token expires during use, PlayFab returns a
401 Unauthorized response. Your application should handle this error by requesting a new token and retrying the call.Troubleshooting
Example error responses
A401 Unauthorized from PlayFab when the Bearer token is missing, malformed, or expired looks like this:
403 Forbidden from PlayFab when the signed-in user is authenticated but lacks admin permissions on the title looks like this:
Limitations
The PlayFab SDKs don’t currently support Entra ID authentication. To call PlayFab APIs with an Entra ID token today, use direct HTTP calls and set theAuthorization: Bearer <token> header yourself, as shown in the C# and Node.js examples. SDK support is planned for a future release.
