Player Authentication API
Introduction
This is the API specification for the Unity Authentication service that allows player authentication.
Rate Limits
The API has rate limiting in place. Most endpoints are limited to 15 requests per second on a per-IP basis, and 300 requests over 30 minutes.
Exceptions are outlined on a per-endpoint basis in the documentation below.
The API responds with a HTTP status code if the rate limit is exceeded.
It also responds with a header to be used in conjunction with a client's retry logic. The value is the number of seconds until a request for the given player to be accepted.
429Retry-AfterDownload OpenAPI specification:
Anonymous Sign Up
Code samples for "{title}":
Request example
curl -X POST \ -H "Content-Type: application/json" \ -d '{ "nonce": "9i09urd6ffg"}' \ "https://player-auth.services.api.unity.com/v1/authentication/anonymous"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
External Token Sign In
Authenticate players using external token. The external tokens are from login providers, such as Facebook.
Code samples for "{title}":
Request example
curl -X POST \ -H "Content-Type: application/json" \ -d '{ "nonce": "5eb26a338a232", "signInOnly": false, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX", "oculusConfig": { "userId": "5eb26a338a232" }, "appleGameCenterConfig": { "teamPlayerId": "5eb26a338a232", "timestamp": 389743847, "publicKeyUrl": "something.com/path.cert", "salt": "ascfr==" }, "steamConfig": { "appId": "123456", "identity": "string" }}' \ "https://player-auth.services.api.unity.com/v1/authentication/external-token/{idProvider}"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Session Token Sign In
Authenticate players using the session token. Store the session token in a persistent storage in the app or on device.
Code samples for "{title}":
Request example
curl -X POST \ -H "Content-Type: application/json" \ -d '{ "nonce": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX", "sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX"}' \ "https://player-auth.services.api.unity.com/v1/authentication/session-token"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Link External Id
Link an External Id to a Unity Authentication account
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Code samples for "{title}":
Request example
curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "forceLink": false, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX", "oculusConfig": { "userId": "5eb26a338a232" }, "appleGameCenterConfig": { "teamPlayerId": "5eb26a338a232", "timestamp": 389743847, "publicKeyUrl": "something.com/path.cert", "salt": "ascfr==" }, "steamConfig": { "appId": "123456", "identity": "string" }}' \ "https://player-auth.services.api.unity.com/v1/authentication/link/{idProvider}"
Response example
{ "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Unlink External Id
Unlink an external account from a Unity Authentication account.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Code samples for "{title}":
Request example
curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "externalId": "eyJhbGciOiJIUzI1Ni"}' \ "https://player-auth.services.api.unity.com/v1/authentication/unlink/{idProvider}"
Response example
{ "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Username Password Sign Up
Create a new player for the Username Password IdProvider. Store the session token in a persistent storage in the app or on device.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Header parameters for "{title}"
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5cThis is the bearer token for the user authorized to call this API. When this is provided, a user associated with the bearer token is used instead of creating a new user.
Code samples for "{title}":
Request example
curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "username": "New_User_57", "password": "ThePassword123!"}' \ "https://player-auth.services.api.unity.com/v1/authentication/usernamepassword/sign-up"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Username Password Sign In
Sign in using the Username Password IdProvider. Store the session token in a persistent storage in the app or on device.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Code samples for "{title}":
Request example
curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "username": "New_User_57", "password": "ThePassword123!"}' \ "https://player-auth.services.api.unity.com/v1/authentication/usernamepassword/sign-in"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Username Password Update Password
Update the password of a player using the Username Password IdProvider. Store the session token in a persistent storage in the app or on device.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Code samples for "{title}":
Request example
curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "password": "ThePassword123!", "newPassword": "TheNewPassword456@"}' \ "https://player-auth.services.api.unity.com/v1/authentication/usernamepassword/update-password"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Generate Code
Generates a sign in code for an unauthenticated device.
Code samples for "{title}":
Request example
curl -X POST \ -H "Content-Type: application/json" \ -d '{ "identifier": "myDevice", "codeChallenge": "string"}' \ "https://player-auth.services.api.unity.com/v1/authentication/code-link/generate"
Response example
{ "codeLinkSessionId": "string", "signInCode": "f4j98K", "expiration": "string"}
Sign In With Code
Tries to sign in a user with code. In the case this returns 200 and an empty response, poll at regular intervals, 2-5s to avoid being rate limited, until you receive a different response.
Code samples for "{title}":
Request example
curl -X POST \ -H "Content-Type: application/json" \ -d '{ "codeVerifier": "string"}' \ "https://player-auth.services.api.unity.com/v1/authentication/code-link/sign-in/{CodeLinkSessionId}"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Get Code Info
Get code information including the identifier and expiration.
Code samples for "{title}":
Request example
curl -X POST \ -H "ProjectId: <ProjectId>" \ -H "UnityEnvironment: <UnityEnvironment>" \ -H "Content-Type: application/json" \ -d '{ "signInCode": "string"}' \ "https://player-auth.services.api.unity.com/v1/authentication/code-link/info"
Response example
{ "identifier": "myDevice", "expiration": "string"}
Code Confirmation
Allow a user to sign in to this account using this code
Code samples for "{title}":
Request example
curl -X POST \ -H "Content-Type: application/json" \ -d '{ "signInCode": "f4j98K", "sessionToken": "string", "idProvider": "string", "externalToken": "string"}' \ "https://player-auth.services.api.unity.com/v1/authentication/code-link/confirm"
Response example
{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ]}
Custom ID Sign In
Sign In using a Custom ID from a trusted server. This endpoint is limited to 500 RPS per IP address.
Authorizations
Admin (player_auth.server.custom_id_auth)
HTTP: Admin
HTTP Authorization Scheme: bearer
Required scopes: player_auth.server.custom_id_auth
Request body for "{title}"
Media Type:
application/jsonexample: eyJhbGciOiJSUzI1NiIsImtpZCI6InB1YmxpYzo3MDdFQkJCNy05MEYzLTQ3NEYtOTA0NC02NDIzRUNDM0Q3NDkiLCJ0eXAiOiJKV1QifQ.eyJdWQiOlsiaWRkOmY1OWRmNDViLWY1YzUtNGE4Yy1iMmM0LWQzNDJiNmM5ZThkZiIsImVudk5hbWU6cHJvZHVjdGlvbiIsImVudklkOmRiNjQ5YzJiLWZjZTAtNDZkZS1iMGFhLTU1MzE1Y2VjYmUwNCIsInVwaWQ6NjU3YjViZGEtZWNmOS00NTFlLTk2NzMtODhlMjg4NTM2MzA1Il0sImV4cCI6MTcxMjg0NjA5NiwiaWF0IjoxNzEyODQyNDk2LCJpZGQiOiJmNTlkZjQ1Yi1mNWM1LTRhOGMtYjJjNC1kMzQyYjZjOWU4ZGYiLCJpc3MiOiJodHRwczovL3BsYXllci1hdXRoLXN0Zy5zZXJ2aWNlcy5hcGkudW5pdHkuY29tIiwianRpIjoiMjIyMjExNGUtMzE4Ni00ODljLTk3YzMtNjg4ZWI2NmJkNDVhIiwibmJmIjoxNzEyODQyNDk2LCJub25jZSI6Im51bGwiLCJwcm9qZWN0X2lkIjoiNjU3YjViZGEtZWNmOS00NTFlLTk2NzMtODhlMjg4NTM2MzA1Iiwic2lnbl9pbl9wcm92aWRlciI6ImFub255bW91cyIsInN1YiI6ImtzOWtJeW1iUnloMFVXVmVJbHBvVXZhR3ZueEoiLCJ0b2tlbl90eXBlIjoiYXV0aGVudGljYXRpb24iLCJ2ZXJzaW9uIjoiMSJ9.iVMwPYOp7qGNdzHS0CqWSdhGE7UTQOL_9J418zUJvlZtmDeslSSEinHAJn_Bv58yaVDNV1Z4dzSdKr5ixVDcxhVpe0lNkThFLRD6r2Ae36NNBKkSztBt9BD14k0_hwyU4beDrY7TUDHNfSppRczkBJAKp5T6eOt3rR9M7ilAOLJLd9Tz5l4aoJWkqG-V-S8qjkDvhiMdHE6HwGk2CVch5MGzTiBqHelCNoroA_cjkLFfUBkT4TTRUMBzXfrsyc8qat1iUPtAjxsvF91Y22d75PiPZAffSaCfT1vzIRWKZQcRH1QQl8BcSFUPGYAKrUKqlvP8njU1GuGYAluxJussegThe access token for the account to be linked.
Code samples for "{title}":
Request example
curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "externalId": "externalId", "signInOnly": false, "accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6InB1YmxpYzo3MDdFQkJCNy05MEYzLTQ3NEYtOTA0NC02NDIzRUNDM0Q3NDkiLCJ0eXAiOiJKV1QifQ.eyJdWQiOlsiaWRkOmY1OWRmNDViLWY1YzUtNGE4Yy1iMmM0LWQzNDJiNmM5ZThkZiIsImVudk5hbWU6cHJvZHVjdGlvbiIsImVudklkOmRiNjQ5YzJiLWZjZTAtNDZkZS1iMGFhLTU1MzE1Y2VjYmUwNCIsInVwaWQ6NjU3YjViZGEtZWNmOS00NTFlLTk2NzMtODhlMjg4NTM2MzA1Il0sImV4cCI6MTcxMjg0NjA5NiwiaWF0IjoxNzEyODQyNDk2LCJpZGQiOiJmNTlkZjQ1Yi1mNWM1LTRhOGMtYjJjNC1kMzQyYjZjOWU4ZGYiLCJpc3MiOiJodHRwczovL3BsYXllci1hdXRoLXN0Zy5zZXJ2aWNlcy5hcGkudW5pdHkuY29tIiwianRpIjoiMjIyMjExNGUtMzE4Ni00ODljLTk3YzMtNjg4ZWI2NmJkNDVhIiwibmJmIjoxNzEyODQyNDk2LCJub25jZSI6Im51bGwiLCJwcm9qZWN0X2lkIjoiNjU3YjViZGEtZWNmOS00NTFlLTk2NzMtODhlMjg4NTM2MzA1Iiwic2lnbl9pbl9wcm92aWRlciI6ImFub255bW91cyIsInN1YiI6ImtzOWtJeW1iUnloMFVXVmVJbHBvVXZhR3ZueEoiLCJ0b2tlbl90eXBlIjoiYXV0aGVudGljYXRpb24iLCJ2ZXJzaW9uIjoiMSJ9.iVMwPYOp7qGNdzHS0CqWSdhGE7UTQOL_9J418zUJvlZtmDeslSSEinHAJn_Bv58yaVDNV1Z4dzSdKr5ixVDcxhVpe0lNkThFLRD6r2Ae36NNBKkSztBt9BD14k0_hwyU4beDrY7TUDHNfSppRczkBJAKp5T6eOt3rR9M7ilAOLJLd9Tz5l4aoJWkqG-V-S8qjkDvhiMdHE6HwGk2CVch5MGzTiBqHelCNoroA_cjkLFfUBkT4TTRUMBzXfrsyc8qat1iUPtAjxsvF91Y22d75PiPZAffSaCfT1vzIRWKZQcRH1QQl8BcSFUPGYAKrUKqlvP8njU1GuGYAluxJusseg"}' \ "https://player-auth.services.api.unity.com/v1/projects/{ProjectId}/authentication/server/custom-id"
Response example
{ "expiresIn": 3600, "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "sessionToken": "5eb26a338a232", "lastNotificationDate": "123000000", "user": { "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1", "username": "New_User_57" }, "userId": "5eb26a338a232"}
Get Player
Get the information for a player.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Code samples for "{title}":
Request example
curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://player-auth.services.api.unity.com/v1/users/{PlayerId}"
Response example
{ "disabled": false, "externalIds": [ { "externalId": "5eb26a338a232", "providerId": "provider-id" } ], "id": "eyJhbGciOiJIUzI1N", "createdAt": "123000000", "lastLoginAt": "123000000", "usernamepassword": { "username": "New_User_57", "createdAt": "123000000", "lastLoginAt": "123000000", "passwordUpdatedAt": "123000000" }}
Delete Player
Delete the player.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer
Code samples for "{title}":
Request example
curl -X DELETE \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://player-auth.services.api.unity.com/v1/users/{PlayerId}"
Response example
{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ]}
Read Notification
Code samples for "{title}":
Request example
curl -X GET \ "https://player-auth.services.api.unity.com/v1/users/{PlayerId}/notifications"
Response example
{ "notifications": [ { "id": "string", "type": "DSA", "playerID": "string", "caseID": "string", "projectID": "string", "message": "string", "createdAt": "string", "updatedAt": "string", "deletedAt": "string" } ]}
Get JWKS
Get the JSON Web Key Set for validating authentication tokens.
Code samples for "{title}":
Request example
curl -X GET \ "https://player-auth.services.api.unity.com/.well-known/jwks.json"
Response example
{ "keys": [ { "alg": "RS256", "e": "43urutru", "kid": "public-0000000-0000-0000-0000-111111111111", "kty": "RSA", "n": "igu4jtou4389ru34890ut90i34r0-i39w4ru90u", "crv": "string", "x": "string", "y": "string", "use": "sig" } ]}