Documentation

Support

Matchmaker

Matchmaker

Authentication

Learn how authentication works in Matchmaker to securely identify and authorize players.
Read time 1 minuteLast updated 2 days ago

There are two ways to authenticate to Matchmaker:
  • Player authentication
  • Service Account authentication

Player authentication

Player authentication uses Unity Authentication to enable player-driven matchmaking so that a game client can contact the Matchmaker service to create a ticket. Make sure to initialize the Authentication service and sign in before making any calls using the Matchmaker SDK. There are multiple ways to sign in, the simplest method is using anonymous sign-in.

Service Account authentication

Service Account authentication is used when a backend service creates a matchmaking ticket on behalf of a game client. This is useful when it is required to add server authoritative data to a matchmaking ticket like a skill value for example. To create a Service Account follow these instructions. To use the Service Account in Matchmaker, follow those steps. Here is an example of a typical service-to-service authentication flow:
  1. The client performs an anonymous authentication as described above in Player authentication.
  2. The client calls a custom backend server with the
    PlayerId
    as the parameter.
  3. The custom backend calls the ticket creation route with the
    impersonate-user-id
    header set to the
    PlayerId
    value:
    curl --location --request POST 'https://matchmaker.services.api.unity.com/v2/tickets' --header 'Content-Type: application/json' --header 'Authorization: {{SERVICE-ACCOUNT-TOKEN}}'--header 'impersonated-user-id: {{PLAYER-ID}}' --data-raw '{ "players": [ { "id": "{{PLAYER-ID}}", "customData": { "Skill": {{ENRICHED-DATA}} } } ] }'
  4. The custom backend sends the ticket ID back to the client.
  5. The client polls the ticket status using the client SDK.