文档

Player Authentication Client API

版本 v1

Player Authentication Client API

版本 v1

Player Authentication Client API

Introduction

Sign players in to Unity Authentication, refresh their sessions, and manage their sign-in methods. The ID token returned on sign-in is the player's credential for most other Unity Gaming Services APIs.

Rate Limits

The API has rate limiting in place. Most endpoints are limited to 15 requests per second and 600 requests per hour on a per-IP basis, shared across those endpoints. Exceptions are noted on the affected endpoints. The API responds with a
429
HTTP status code if a rate limit is exceeded, and a
Retry-After
header with the number of seconds until requests are accepted again.
Download OpenAPI specification:

Anonymous Sign Up


Sign-up a new anonymous player.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

nonce

string
String value used to associate a client session with an Id Token, and to mitigate replay attacks. If this field is provided, the nonce claim in response id token has a matching value.
example: 9i09urd6ffg

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -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"}

Session Token Sign In


Authenticate players using the session token. Store the session token in a persistent storage in the app or on device.
Set
singleUse
,
audiences
or
ttlSeconds
to receive a new, restricted child session token instead, for handing to a less-trusted context such as a browser. The presented token stays valid unless it is single-use. Restrictions on the child session token are inherited by every later refresh and never loosened, except by an Origin policy (see
narrowOnly
).
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

nonce

string
String value used to associate a Client session with an Id Token, and to mitigate replay attacks. If this field is provided, the nonce claim in response Id token has a matching value.
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX

sessionToken

string
必填
The session token of the player.
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX

singleUse

boolean
默认: false
Make the child session token single-use, so its first refresh consumes it. Inherited, and cannot be cleared by a later refresh.
example: true

audiences

array[string]
Scope the child session token to these services. Each entry adds
svc:<name>
to the ID token's
aud
, and audience-checked routes outside the set reject it. A service's name is a segment of its production URL, e.g.
cloud-save
for
cloud-save.services.api.unity.com
. Ignored if the presented token is already scoped.
player-auth
gates this API's player-management routes (Get and Delete Player, link, unlink, username/password sign-up and password change, code-link confirm, notifications), not sign-in or refresh.
maxItems: 8
items: pattern: ^[a-z0-9-]{1,64}$
example: ["cloud-save","leaderboards"]

ttlSeconds

integer
Expire the child session token after this many seconds, capped at the presented token's expiry.
format: int64>= 1<= 31536000
example: 60

narrowOnly

boolean
默认: false
Stop Origin policies from widening this token's restrictions. Some Unity web origins apply their own restrictions on the first refresh from them, by default replacing the session token's audiences and expiry, which can widen them. With
narrowOnly
, the policy's audiences are intersected with the token's and its expiry applies only if sooner. It still adds single-use and binds the session token to the origin. Fields left unset take the policy's value. If the token's audiences share none with the policy's, that refresh is rejected. Inherited, and cannot be cleared by a later refresh.
example: true

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "nonce": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX", "sessionToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX", "singleUse": true, "audiences": [ "cloud-save", "leaderboards" ], "ttlSeconds": 60, "narrowOnly": true}' \ "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"}

External Token Sign In


Authenticate players using external token. The external tokens are from login providers, such as Facebook.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

idProvider

string
必填
This is the id provider type.
example: identity-provider-name

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

nonce

string
String value used to associate a client session with an Id token, and to mitigate replay attacks. If this field is provided, the nonce claim in response Id token has a matching value.
example: 5eb26a338a232

signInOnly

boolean
Whether the API should only attempt to sign-in and do not create a new player if the player does not exist.
example: false

token

string
必填
External token that can be verified to represent a player from the id provider. This may be an id token or an access token.
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX

oculusConfig

object
The request body for Oculus authentication. This field is not applicable for any other Id provider.

userId

string
必填
String value of the oculus player's Id.
example: 5eb26a338a232

appleGameCenterConfig

object
The request body for Apple Game Center authentication. This field is not applicable for any other Id provider.

teamPlayerId

string
必填
String value of the Apple Game Center player's team player Id.
example: 5eb26a338a232

timestamp

integer
必填
Integer value of the timestamp.
example: 389743847

publicKeyUrl

string
必填
String value of the Apple Game Center public key url.
example: something.com/path.cert

salt

string
必填
String value of the base64 encoded salt.
example: ascfr==

steamConfig

object
Identifying string passed as a parameter to Steam's GetAuthTicketForWebApi when the ticket was created, used to identify the entity calling this webapi. This should not be sent if no identity was passed issue a ticket from steam.

appId

string
The app Id of the game.
example: 123456

identity

string
If this identity string was passed to GetAuthTicketForWebApi then the same value must be provided as the identity property. This value should be the comprised of alphanumeric characters with a length between 5 and 30.
minLength: 5maxLength: 30

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -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"}

Link External Id


Link an external ID to a Unity Authentication player.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

idProvider

string
必填
This is the id provider type.
example: identity-provider-name

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Request body for "{title}"

Media Type:
application/json

forceLink

boolean
Force a link between the player specified in the player-auth access token and the external Id. If a different player-auth player is already linked to the external id, unlink that player from the external id before linking the request's player.
example: false

token

string
必填
External token that can be verified to represent a player from the Id provider. This may be an Id token or an access token.
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX

oculusConfig

object
The request body for Oculus authentication. This field is not applicable for any other Id provider.

userId

string
必填
String value of the oculus player's Id.
example: 5eb26a338a232

appleGameCenterConfig

object
The request body for Apple Game Center authentication. This field is not applicable for any other Id provider.

teamPlayerId

string
必填
String value of the Apple Game Center player's team player Id.
example: 5eb26a338a232

timestamp

integer
必填
Integer value of the timestamp.
example: 389743847

publicKeyUrl

string
必填
String value of the Apple Game Center public key url.
example: something.com/path.cert

salt

string
必填
String value of the base64 encoded salt.
example: ascfr==

steamConfig

object
Identifying string passed as a parameter to Steam's GetAuthTicketForWebApi when the ticket was created, used to identify the entity calling this webapi. This should not be sent if no identity was passed issue a ticket from steam.

appId

string
The app Id of the game.
example: 123456

identity

string
If this identity string was passed to GetAuthTicketForWebApi then the same value must be provided as the identity property. This value should be the comprised of alphanumeric characters with a length between 5 and 30.
minLength: 5maxLength: 30

HTTP response status codes for "{title}":

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 ID from a Unity Authentication player.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

idProvider

string
必填
This is the id provider type.
example: identity-provider-name

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Request body for "{title}"

Media Type:
application/json

externalId

string
必填
The external ID to unlink from the player.
example: eyJhbGciOiJIUzI1Ni

HTTP response status codes for "{title}":

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"}

Get Player


Get the information for a player.
Requests with a player token are limited to 600 requests per minute per player, instead of the per-IP limits.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

PlayerId

string
必填
This is the player id.
example: 99i9ju8juh

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

HTTP response status codes for "{title}":

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

Path parameters for "{title}"

PlayerId

string
必填
This is the player id.
example: 99i9ju8juh

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

HTTP response status codes for "{title}":

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" } ]}

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

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

username

string
必填
The username. Case insensitive. Length must be between 3-20 with the allowed characters a-z, 0-9 and the symbols [.][-][@][_].
example: New_User_57

password

string
必填
The password. Length must be between 8-30 and contain at least one uppercase letter, at least one lowercase letter, at least one number and at least one symbol.
example: ThePassword123!

HTTP response status codes for "{title}":

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 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}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Authorization

string
This 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.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Request body for "{title}"

Media Type:
application/json

username

string
必填
The username. Case insensitive. Length must be between 3-20 with the allowed characters a-z, 0-9 and the symbols [.][-][@][_].
example: New_User_57

password

string
必填
The password. Length must be between 8-30 and contain at least one uppercase letter, at least one lowercase letter, at least one number and at least one symbol.
example: ThePassword123!

HTTP response status codes for "{title}":

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 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. This endpoint is limited to 30 requests per minute per IP address instead of 15 per second. The shared 600 requests per hour limit still applies.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Request body for "{title}"

Media Type:
application/json

password

string
必填
The password. Length must be between 8-30 and contain at least one uppercase letter, at least one lowercase letter, at least one number and at least one symbol.
example: ThePassword123!

newPassword

string
必填
The password to be changed. Length must be between 8-30 and contain at least one uppercase letter, at least one lowercase letter, at least one number and at least one symbol.
example: TheNewPassword456@

HTTP response status codes for "{title}":

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. This endpoint is limited to 30 requests per minute per IP address instead of 15 per second. The shared 600 requests per hour limit still applies.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

identifier

string
Human-readable string to identify the requester device.
maxLength: 128
example: myDevice

codeChallenge

string
必填
SHA-256 string challenge for PKCE validation
maxLength: 64

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -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"}

Get Code Info


Get code information including the identifier and expiration. This endpoint is limited to 30 requests per minute per IP address instead of 15 per second. The shared 600 requests per hour limit still applies.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

signInCode

string
必填
The code from which to get the info.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "ProjectId: <ProjectId>" \ -H "UnityEnvironment: <UnityEnvironment>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -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"}

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. This endpoint is limited to 30 requests per minute per IP address instead of 15 per second. The shared 600 requests per hour limit still applies.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

CodeLinkSessionId

string
必填
An identifier for the device requesting the code sign in.

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

codeVerifier

string
必填
Verifier for PKCE validation.
>= 43maxLength: 128

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -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"}

Code Confirmation


Confirm a sign-in code, so the device that generated it signs in as this player. This endpoint is limited to 30 requests per minute per IP address instead of 15 per second. The shared 600 requests per hour limit still applies.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Header parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Request body for "{title}"

Media Type:
application/json

signInCode

string
必填
The code returned in the GenerateCodeResponse.
example: f4j98K

sessionToken

string
The authenticated device session token, for added security.

idProvider

string
This is the id provider type. Only for consoles.

externalToken

string
External token to validate the user. Only for consoles.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -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.
Set
sessionTokenRestrictions
to mint a restricted session token directly, rather than narrowing an unrestricted one with a session-token refresh.
Authorizations
Admin (player_auth.server.custom_id_auth)
HTTP: Admin
HTTP Authorization Scheme: bearer
Required scopes: player_auth.server.custom_id_auth

Path parameters for "{title}"

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.

Header parameters for "{title}"

UnityEnvironment

string | null
This is the Environment you want to authorize a player to access. It is the name of the Environment. If this header is not specified, then the default Environment is used. An invalid environment name is not an acceptable input.
example: production

Request body for "{title}"

Media Type:
application/json

externalId

string
必填
The external id used to identify the player. Length must be between 1-320.
example: externalId

signInOnly

boolean
Whether the API should only attempt to sign-in and do not create a new player if the player does not exist.
example: false

accessToken

string
The access token of the existing player to link this Custom ID to.
example: eyJhbGciOiJSUzI1NiIsImtpZCI6InB1YmxpYzo3MDdFQkJCNy05MEYzLTQ3NEYtOTA0NC02NDIzRUNDM0Q3NDkiLCJ0eXAiOiJKV1QifQ.eyJdWQiOlsiaWRkOmY1OWRmNDViLWY1YzUtNGE4Yy1iMmM0LWQzNDJiNmM5ZThkZiIsImVudk5hbWU6cHJvZHVjdGlvbiIsImVudklkOmRiNjQ5YzJiLWZjZTAtNDZkZS1iMGFhLTU1MzE1Y2VjYmUwNCIsInVwaWQ6NjU3YjViZGEtZWNmOS00NTFlLTk2NzMtODhlMjg4NTM2MzA1Il0sImV4cCI6MTcxMjg0NjA5NiwiaWF0IjoxNzEyODQyNDk2LCJpZGQiOiJmNTlkZjQ1Yi1mNWM1LTRhOGMtYjJjNC1kMzQyYjZjOWU4ZGYiLCJpc3MiOiJodHRwczovL3BsYXllci1hdXRoLXN0Zy5zZXJ2aWNlcy5hcGkudW5pdHkuY29tIiwianRpIjoiMjIyMjExNGUtMzE4Ni00ODljLTk3YzMtNjg4ZWI2NmJkNDVhIiwibmJmIjoxNzEyODQyNDk2LCJub25jZSI6Im51bGwiLCJwcm9qZWN0X2lkIjoiNjU3YjViZGEtZWNmOS00NTFlLTk2NzMtODhlMjg4NTM2MzA1Iiwic2lnbl9pbl9wcm92aWRlciI6ImFub255bW91cyIsInN1YiI6ImtzOWtJeW1iUnloMFVXVmVJbHBvVXZhR3ZueEoiLCJ0b2tlbl90eXBlIjoiYXV0aGVudGljYXRpb24iLCJ2ZXJzaW9uIjoiMSJ9.iVMwPYOp7qGNdzHS0CqWSdhGE7UTQOL_9J418zUJvlZtmDeslSSEinHAJn_Bv58yaVDNV1Z4dzSdKr5ixVDcxhVpe0lNkThFLRD6r2Ae36NNBKkSztBt9BD14k0_hwyU4beDrY7TUDHNfSppRczkBJAKp5T6eOt3rR9M7ilAOLJLd9Tz5l4aoJWkqG-V-S8qjkDvhiMdHE6HwGk2CVch5MGzTiBqHelCNoroA_cjkLFfUBkT4TTRUMBzXfrsyc8qat1iUPtAjxsvF91Y22d75PiPZAffSaCfT1vzIRWKZQcRH1QQl8BcSFUPGYAKrUKqlvP8njU1GuGYAluxJusseg

sessionTokenRestrictions

object
Restrictions on the session token minted by this sign-in. Later refreshes treat them exactly as restrictions set on Session Token Sign In, including that an Origin policy can replace
audiences
and
ttlSeconds
unless
narrowOnly
is set. Omit for an unrestricted session.

singleUse

boolean
默认: false
Make the session token single-use, so its first refresh consumes it.
example: true

audiences

array[string]
Scope the session token to these services, as
audiences
on Session Token Sign In.
maxItems: 8
items: pattern: ^[a-z0-9-]{1,64}$
example: ["cloud-save","leaderboards"]

ttlSeconds

integer
Expire the session token after this many seconds. The returned ID token expires no later than this.
format: int64>= 1<= 31536000
example: 60

narrowOnly

boolean
默认: false
Make these restrictions a ceiling for Origin policies, as
narrowOnly
on Session Token Sign In. Set it when the token must not gain audiences such as
player-auth
from an Origin policy, e.g. for a player identity your server has not verified. A short
ttlSeconds
will not be extended, so usually leave it off.
example: true

HTTP response status codes for "{title}":

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", "sessionTokenRestrictions": { "singleUse": true, "audiences": [ "cloud-save", "leaderboards" ], "ttlSeconds": 60, "narrowOnly": true }}' \ "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"}

Read Notification


Gets a player's notifications to be displayed by the client.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

PlayerId

string
必填
This is the player id.
example: 99i9ju8juh

Header parameters for "{title}"

Authorization

string
This is the bearer token for the user authorized to call this API.
example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

ProjectId

string
必填
This is the Unity Project Id. It is a uuid format.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "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" } ]}