文档

​
​

Development

User Acquisition

Monetization

工业

Resource Policy API

v1

受支持
​

Resource Policy API

v1

受支持
​

此页面不支持所选语言。
Unity Services Web APIs
​
​
mdx:openapi:endpoints
  • PlayerPolicy
  • ProjectPolicy

Access Resource Policy API

This service allows customers and administrators to restrict resources (project and player) read/write access for gaming services.
Download OpenAPI specification:

Get a project based policy


A policy consists of multiple policy statements. This endpoint will return a Policy object containing an array of all non-expired policy statements in that policy.
Authorizations
ServiceAccount (unity.project_resource_policy.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.project_resource_policy.get
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/resource-policy"

Response example

{ "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}

Create or update a project based policy


Create or update a project based policy. A maximum of 500 non-expired statements per policy can be created/updated.
Authorizations
ServiceAccount (unity.project_resource_policy.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.project_resource_policy.update
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

Request body for "{title}"

Media Type:
application/json

statements

array[object]
No description

Sid

string
必填
example: statement_id1
Statement ID. Consists of alphanumeric characters and hyphen, and must be of length between 6 and 60 chars.

Action

array[string]
必填
User action against which the policy statement will be applicable. Allowable values are "Read", "Write", "*", "Vivox:JoinMuted", "Vivox:JoinAllMuted, "Vivox:JoinWithConsent", "Vivox:JoinWithConsent".

Effect

string
必填
Effect of the policy statement. Allowable values are "Allow" and "Deny"

Principal

string
必填
The principal the statement applies to, Allowed values are "Player" and "Unauthenticated"

Resource

string
必填
example: urn:ugs:cloud-save:*
Uniform resource name of the resource(s) being targeted by the policy. The format is
urn:ugs:<service-name>:/<path>
. For example,
urn:ugs:*
targets all services. Some other examples are
  • urn:ugs:cloud-code:/v1/projects/*/scripts/*
  • urn:ugs:economy:/*

ExpiresAt

string
example: 2020-07-20T18:30:51.243Z
UTC time (ISO 8601 extended format) when the policy expires

Version

string
No description

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X PATCH \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/resource-policy"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Delete policy statement(s)


Delete policy statement(s) for project-based policy.
Authorizations
ServiceAccount (unity.project_resource_policy.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.project_resource_policy.update
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

Request body for "{title}"

Media Type:
application/json

statementIDs

array[string]
必填
example: ["statementId1","statementId2"]
Array of statement IDs which are to be deleted from the policy

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statementIDs": [ "statementId1", "statementId2" ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/resource-policy:delete-statements"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Get a player based policy


A policy consists of multiple policy statements. This endpoint will return a Policy object containing an array of all non-expired policy statements in that policy.
Authorizations
ServiceAccount (unity.player_resource_policy.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.get
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

playerId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0c
ID of the player

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/{playerId}/resource-policy"

Response example

{ "playerId": "HgIZuzj0MwDwPO062o0BSVxAcFAV", "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}

Create or update a player based policy


Create or update a player based policy. A maximum of 500 non-expired statements per policy can be created/updated.
Authorizations
ServiceAccount (unity.player_resource_policy.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.update
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

playerId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0c
ID of the player

Request body for "{title}"

Media Type:
application/json

statements

array[object]
No description

Sid

string
必填
example: statement_id1
Statement ID. Consists of alphanumeric characters and hyphen, and must be of length between 6 and 60 chars.

Action

array[string]
必填
User action against which the policy statement will be applicable. Allowable values are "Read", "Write", "*", "Vivox:JoinMuted", "Vivox:JoinAllMuted", "Vivox:JoinWithConsent".

Effect

string
必填
Effect of the policy statement. Allowable values are "Allow" and "Deny"

Principal

string
必填
The principal the statement applies to, Allowed value is "Player"

Resource

string
必填
example: urn:ugs:cloud-save:*
Uniform resource name of the resource(s) being targeted by the policy. The format is
urn:ugs:<service-name>:/<path>
. For example,
urn:ugs:*
targets all services. Some other examples are
  • urn:ugs:cloud-code:/v1/projects/*/scripts/*
  • urn:ugs:economy:/*

ExpiresAt

string
example: 2020-07-20T18:30:51.243Z
UTC time (ISO 8601 extended format) when the policy expires

Version

string
No description

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X PATCH \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/{playerId}/resource-policy"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Delete policy statement(s)


Delete policy statement(s) for player-based policy.
Authorizations
ServiceAccount (unity.player_resource_policy.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.update
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

playerId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0c
ID of the player

Request body for "{title}"

Media Type:
application/json

statementIDs

array[string]
必填
example: ["statementId1","statementId2"]
Array of statement IDs which are to be deleted from the policy

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statementIDs": [ "statementId1", "statementId2" ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/{playerId}/resource-policy:delete-statements"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Get all player based policies in project


This endpoint returns all player based policies which belong to a specific project and environment.
By default, the API returns 5 results per page. The number of results per page can be customized by including the limit query parameter in the request. To retrieve subsequent pages of results, pass the next query parameter, the value of which will be provided in the response body of the first paginated response.
Authorizations
ServiceAccount (unity.player_resource_policy.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.get
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

projectId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
必填
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

Query parameters for "{title}"

limit

integer
example: 5
max results per page - is ignored if
next
query parameter is provided

next

string
example: eyJuZXh0IjoiNTliZDIwYjItMWE5My00Y2YxLWJhZWYtYWY3ZTJiNThmZGY2IiwibGltaXQiOjN9
pagination token for requesting next page of results

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/resource-policy"

Response example

{ "next": "eyJuZXh0IjoiNTliZDIwYjItMWE5My00Y2YxLWJhZWYtYWY3ZTJiNThmZGY2IiwibGltaXQiOjN9", "results": [ { "playerId": "HgIZuzj0MwDwPO062o0BSVxAcFAV", "statements": [ { "Sid": "statement_id1", "Action": [ null ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ] } ]}

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。