Authentication
There are two ways to authenticate to Matchmaker:
- Player Authentication
- Service Account Authentication
Player authentication
Player authentication is used to enable player driven matchmaking, where a game client contacts directly the Matchmaker service to create a ticket. It uses Unity Authentication.
Make sure to initialize the authentication service and sign-in before making any call using the Matchmaker SDK.
There are multiple ways to sign-in, the most straight forward is 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:
The client performs an anonymous authentication as described above in Player authentication.
The client calls a custom backend server with the
PlayerId
as the parameterThe custom backend calls the ticket creation route with the
impersonate-user-id
header set to thePlayerId
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}} } } ] }'
The custom backend sends the ticket id back to the client
The client polls the ticket status using the client SDK