文档

​
​

Development

User Acquisition

Monetization

工业

Unity Services Web APIs

Open Unity Dashboard

Unity Services Web APIs

此页面不支持所选语言。
​
​
Unity Services Web APIs
  • Overview
  • Get started
Web API guides
  • Authentication
    • Admin authentication
    • Client authentication
  • API lifecycle
  • Response status and error codes
  • Response headers
  • Unity Version Control CM API
  • Unity Version Control server API
Admin Settings
  • Access
  • Unity Releases
Analytics
  • Analytics
Identity and Access Management
  • Application and Deep Linking
Monetization
  • Monetize
Viewers and Collaboration
  • Annotations
  • Presence
Access
  • Access
Assets
  • Assets
Auth
  • Auth
Collaboration
  • Collaboration
Content Management
  • DataStreaming
  • Storage
  • Workflow Engine
DevOps
  • Automation
  • Build Automation
  • Unity Version Control
Growth
  • Ads Unified Platform
  • User Acquisition
Identity
  • SCIM
In-App Purchases
  • Webshop
Live Operations
  • Game Backend
  • Observability Logs
Multiplayer
  • Distributed Authority
  • Friends
  • Lobby
  • Matchmaker
  • Player Names
  • QoS Discovery
  • Relay Allocations
  • Session Observability
  • Vivox Voice and Text Chat
Unity
  • Projects and Apps
Unity Pipeline
  • Asset Pipeline
  1. Unity Services Web APIs

Admin authentication

Learn how to authenticate admin APIs using service accounts and stateless tokens.
阅读时间3 分钟
最后更新于 25 天前

Admin APIs allow you to access and configure Unity Services as an administrator. To authenticate admin APIs, you must create and use service accounts.

Supported APIs

Some APIs directly support service account authentication, while others require an additional stateless token.
These APIs directly support service accounts:
  • Authentication
  • Advertising Management
  • Advertising Statistics
  • Assets Manager
  • Assets External Providers
  • Collaboration
  • Application Linking
  • Annotations
  • Presence
  • Mediation
  • Cloud Save
  • Economy
  • Triggers
  • Scheduler
  • Cloud Code
  • Leaderboards
  • Matchmaker
  • Session Observability
  • Remote Config
  • SCIM
  • Content Delivery Management
  • Player Authentication
  • Resource Policy
  • Access (deprecated)
  • Safe Voice
  • Vivox Moderation
  • Moderation
  • Text Evidence Management
  • Server Side Recording
  • Vivox Safe Text
  • Storage
  • Observability
  • Instance Metadata
  • Workflow Engine
These APIs require an additional stateless token:
  • Cloud Save
  • Economy
  • Cloud Code
  • Leaderboards
  • Lobby
  • Matchmaker
  • Friends
  • Player Names

Prerequisites

Before you use service accounts, make sure you are an Organization Owner or Organization Manager.

Create a service account

To create a service account, follow these steps:
  1. In the Unity Dashboard, open the Account menu and select Manage organization.
  2. In the Administration menu, select Service Accounts.
  3. Select Create service account to create a new account.
  4. In the Keys section, select Create key to generate a key ID and a secret key.
  5. Add a role to your service account to allow access to API endpoints.
    • Select Add organization role to grant access to organization-level data that applies to all projects in your organization.
    • Select Add project role to grant access to project-level data that applies to individual projects.
You can now use either your service account credentials or a stateless authentication token to authenticate and call an API.

Authenticate an API using service account credentials

To authenticate an API using your service account credentials, open a terminal and enter the following authorization HTTP header:
curl -H "Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS>" \https://services.api.unity.com/<ENDPOINT>
The
<SERVICE_ACCOUNT_CREDENTIALS>
is created by Base64 encoding the string
<KEY_ID>:<SECRET_KEY>
. It uses the key ID and secret key you generated when you created a service account.
For example, if your key ID is
7e0f1152-e0dd-4b14-8e37-04cab07efeb0
and your secret key is
NKxoRp2m2w3e9gzJfssNQnTfypFgtJn7
, your header will be
7e0f1152-e0dd-4b14-8e37-04cab07efeb0:NKxoRp2m2w3e9gzJfssNQnTfypFgtJn7
.

Authenticate an API with the Unix terminal

重要
You must Base64 encode the key string before authenticating an API with the Unix terminal.
If you're using a Unix terminal, follow these steps:
  1. Enter a command to Base64 encode the key string.
echo -n "7e0f1152-e0dd-4b14-8e37-04cab07efeb0:NKxoRp2m2w3e9gzJfssNQnTfypFgtJn7" | base64
  1. Replace
    <SERVICE_ACCOUNT_CREDENTIALS>
    with the output from the previous command.
curl -H "Authorization: Basic N2UwZjExNTItZTBkZC00YjE0LThlMzctMDRjYWIwN2VmZWIwOk5LeG9ScDJtMnczZTlnekpmc3NOUW5UZnlwRmd0Sm43" \https://services.api.unity.com/<ENDPOINT>
You have now authenticated your API.

Authenticate an API using a stateless token

To authenticate an API using a stateless token, follow these steps:
  1. Call the Token Exchange API. Make sure to send your key ID and your secret key as the authorization in the request.
curl -X POST -H "Authorization: Basic N2UwZjExNTItZTBkZC00YjE0LThlMzctMDRjYWIwN2VmZWIwOk5LeG9ScDJtMnczZTlnekpmc3NOUW5UZnlwRmd0Sm43" \https://services.api.unity.com/auth/v1/token-exchange?projectId=<PROJECT_ID>&environmentId=<ENVIRONMENT_ID>
As a response, you receive an
accessToken
.
{ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9.tbDepxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ",}
  1. Use the
    accessToken
    to call APIs in the context of the project ID and/or environment ID you specified earlier.
curl -H "Authorization: Bearer <STATELESS_ACCESS_TOKEN>" \https://services.api.unity.com/<ENDPOINT>

Refresh your stateless token

The stateless access token you receive after calling the Token Exchange API includes an
exp
field which determines the token's lifespan. If your token expires, you can refresh it by calling the Token Exchange API again with your original key ID and secret key.
You can generate a new token before your previous token has expired. Generating a new token doesn't invalidate your previous token.

Available roles

To view and manage the available roles for admin API authentication, go to Unity Cloud, open the Account menu, select Manage organization, then in the Administration menu, select Service Accounts, and select a service account to see its assigned roles and permissions.

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

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

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

  • 在本页上
    • Supported APIs

    • Prerequisites

    • Create a service account

    • Authenticate an API using service account credentials

      • Authenticate an API with the Unix terminal

    • Authenticate an API using a stateless token

      • Refresh your stateless token

    • Available roles