Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trước khi bắt đầu phát triển, bạn cần xem lại
Điều khoản dịch vụ của API Chính sách Chrome,
tạo dự án Google Cloud, bật API Chính sách Chrome và thiết lập
thông tin xác thực quyền truy cập.
Bạn cần có dự án trên Google Cloud để sử dụng API Chính sách của Chrome. Dự án này tạo cơ sở để tạo, bật và sử dụng tất cả dịch vụ của Google Cloud, bao gồm cả việc quản lý API, bật tính năng thanh toán, thêm và xoá cộng tác viên cũng như quản lý quyền.
Nếu chưa có dự án Google Cloud mà bạn muốn sử dụng, hãy làm theo các bước bên dưới để tạo một dự án trên Google Cloud:
Ở trên cùng bên trái, hãy nhấp vào biểu tượng Trình đơn menu>IAM & Admin>Tạo dự án.
Trong trường Tên dự án, hãy nhập tên mô tả cho dự án của bạn.
Trong trường Vị trí, hãy nhấp vào Duyệt qua để hiển thị các tổ chức có thể chỉ định. Chọn tổ chức mà bạn muốn quản lý các chính sách của Chrome, sau đó nhấp vào Chọn.
Nhấp vào Tạo. Bảng điều khiển sẽ chuyển đến Trang tổng quan và dự án của bạn sẽ được tạo trong vòng vài phút.
Bước 2: Bật Chrome Policy API
Cách bật API Chrome Policy trong dự án Google Cloud:
Ở trên cùng, hãy chọn dự án của bạn trên Google Cloud.
Ở trên cùng bên trái, hãy nhấp vào biểu tượng Trình đơn menu>API và dịch vụ>Màn hình xin phép bằng OAuth.
Chọn loại người dùng cho ứng dụng của bạn, sau đó nhấp vào Tạo.
Hoàn tất biểu mẫu đăng ký ứng dụng, sau đó nhấp vào Lưu và tiếp tục.
Nhấp vào Thêm hoặc xoá phạm vi. Một bảng điều khiển sẽ xuất hiện với danh sách các phạm vi cho từng API mà bạn đã bật trong dự án trên Google Cloud. Thêm một trong các phạm vi uỷ quyền sau:
Ở trên cùng, hãy chọn dự án của bạn trên Google Cloud.
Ở trên cùng bên trái, hãy nhấp vào biểu tượng Trình đơn menu>API và dịch vụ>Thông tin xác thực.
Nhấp vào Tạo thông tin xác thực>Mã ứng dụng khách OAuth.
Làm theo các bước để tạo thông tin xác thực OAuth 2.0.
Quản trị viên Chrome của tổ chức không cần phải thiết lập đặc biệt để xác thực OAuth 2.0. Người dùng ứng dụng của bạn sẽ cần có
các quyền bắt buộc đối với vai trò quản trị viên
liên kết với tài khoản của họ và cần phải đồng ý với màn hình xin phép bằng OAuth của ứng dụng.
Tài khoản dịch vụ là một loại tài khoản đặc biệt mà một ứng dụng sử dụng chứ không phải một người. Bạn có thể sử dụng tài khoản dịch vụ để truy cập vào dữ liệu hoặc thực hiện các thao tác
bằng chính tài khoản rô-bốt hoặc để truy cập vào dữ liệu thay mặt cho người dùng.
Để biết thêm thông tin chi tiết, hãy tham khảo bài viết Tìm hiểu về tài khoản dịch vụ.
Không bắt buộc: Nhập những người dùng hoặc nhóm có thể quản lý và thực hiện các thao tác với tài khoản dịch vụ này. Để biết thêm chi tiết, hãy tham khảo bài viết Quản lý mạo danh tài khoản dịch vụ.
Nhấp vào Xong. Sau vài phút, tài khoản dịch vụ mới của bạn sẽ xuất hiện trong danh sách "Tài khoản dịch vụ". (Bạn có thể cần phải làm mới trang.)
Trong danh sách "Tài khoản dịch vụ", hãy nhấp vào tài khoản dịch vụ mà bạn đã tạo.
Nhấp vào Khoá>Thêm khoá>Tạo khoá mới.
Chọn JSON, rồi nhấp vào Tạo.
Cặp khoá công khai/riêng tư mới của bạn sẽ được tạo và tải xuống máy của bạn dưới dạng tệp mới. Tệp này là bản sao duy nhất của khoá này. Để biết thông tin về cách lưu trữ an toàn khoá của bạn, hãy xem bài viết Quản lý khoá tài khoản dịch vụ.
Uỷ quyền tài khoản dịch vụ trong Bảng điều khiển dành cho quản trị viên
Nếu bạn chọn xác thực yêu cầu dưới dạng tài khoản dịch vụ, thì quản trị viên Chrome của tổ chức cần thực hiện thêm một số bước trong Bảng điều khiển dành cho quản trị viên để hoàn tất quy trình này.
Để thiết lập tính năng uỷ quyền trên toàn miền cho tài khoản dịch vụ, quản trị viên Chrome cần làm theo các bước sau trong Bảng điều khiển dành cho quản trị viên:
Trong trường "Phạm vi OAuth", hãy nhập danh sách được phân tách bằng dấu phẩy gồm các phạm vi mà ứng dụng tài khoản dịch vụ yêu cầu. Đây cũng là nhóm phạm vi được xác định khi định cấu hình màn hình xin phép bằng OAuth.
Ở trên cùng, hãy chọn dự án của bạn trên Google Cloud.
Ở trên cùng bên trái, hãy nhấp vào biểu tượng Trình đơn menu>API và dịch vụ>Thông tin xác thực.
Nhấp vào Tạo thông tin xác thực>Mã ứng dụng khách OAuth.
Nhấp vào Loại ứng dụng>Ứng dụng web.
Trong trường "Tên", hãy nhập tên cho thông tin xác thực. Tên này chỉ xuất hiện trong Cloud Console.
Trong thời gian thử nghiệm, hãy thêm https://developers.google.com/oauthplayground vào phần "URI chuyển hướng được uỷ quyền". Bạn có thể xoá URI chuyển hướng này khỏi ứng dụng của mình khi hoàn tất quá trình kiểm thử (nếu cần).
Nhấp vào Tạo rồi sao chép "mã ứng dụng khách" và "mật khẩu ứng dụng khách" vào bảng nhớ tạm.
Ở trên cùng bên phải, hãy nhấp vào biểu tượng Cấu hình OAuth 2.0 settings.
Chọn Sử dụng thông tin xác thực OAuth của riêng bạn. Sau đó, dán "client ID" (mã ứng dụng khách) và "client secret" mà bạn đã sao chép ở bước 8 rồi nhấp vào Close (Đóng).
Ở bên trái, hãy làm theo các bước trong Playground OAuth 2.0:
Đối với "Bước 1: Chọn và cho phép API", hãy thêm https://www.googleapis.com/auth/chrome.management.policy và mọi phạm vi API cần thiết khác, sau đó nhấp vào Uỷ quyền API.
Đối với "Bước 2: Trao đổi mã uỷ quyền để lấy mã thông báo", bạn có thể chọn Tự động làm mới mã thông báo trước khi hết hạn (không bắt buộc).
Đối với "Bước 3: Định cấu hình yêu cầu cho API", hãy nhập URI yêu cầu API Chính sách của Chrome, sửa đổi "Phương thức HTTP" và các chế độ cài đặt khác nếu cần. Yêu cầu URL mẫu: https://chromepolicy.googleapis.com/v1/customers/my_customer/policySchemas?filter=chrome.printers
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eBefore starting development, review the Chrome Policy API Terms of Service, create a Google Cloud project, enable the Chrome Policy API, and set up access credentials.\u003c/p\u003e\n"],["\u003cp\u003eYou need to create a Google Cloud project to utilize the Chrome Policy API, which enables API management, billing, collaboration, and permission control.\u003c/p\u003e\n"],["\u003cp\u003eThe Chrome Policy API allows for end-user or service account authentication, with specific steps provided for setting up each method.\u003c/p\u003e\n"],["\u003cp\u003eTo authorize your application, you may need to configure OAuth consent screen and potentially domain-wide delegation in the Admin console.\u003c/p\u003e\n"],["\u003cp\u003eUse the OAuth Playground for testing your application's functionality and ensure your application is marked as trusted by the organization's administrator in the Admin console.\u003c/p\u003e\n"]]],[],null,["# Set up & authorize requests\n\nBefore you begin developing, you need to review the\n[Chrome Policy API Terms of Service](http://console.cloud.google.com/tos?id=chrome-policy),\ncreate a Google Cloud project, enable the Chrome Policy API, and set up\naccess credentials.\n\nThe Chrome Policy API respects [admin role permissions](/chrome/policy/guides/policy-schemas#namespaces)\nand is governed by defined [authorization scopes](#step_3_create_credentials).\n\nStep 1: Create a Google Cloud project\n-------------------------------------\n\nA Google Cloud project is required to use the Chrome Policy API. This project\nforms the basis for creating, enabling, and using all Google Cloud services,\nincluding managing APIs, enabling billing, adding and removing collaborators,\nand managing permissions.\n\nIf you don't already have a Google Cloud project you want to use, follow the\nsteps below to create a Google Cloud project:\n\n1. Open the [Google Cloud Console](https://console.cloud.google.com/).\n2. At the top-left, click Menu menu \\\u003e **IAM \\& Admin** \\\u003e **Create a Project**.\n3. In the **Project Name** field, enter a descriptive name for your project.\n4. In the **Location** field, click **Browse** to display the organizations available for assignment. Choose the organization for which you want to manage Chrome policies, then click **Select**.\n5. Click **Create**. The console navigates to the Dashboard page and your project is created within a few minutes.\n\nStep 2: Enable the Chrome Policy API\n------------------------------------\n\nTo enable the Chrome Policy API in your Google Cloud project:\n| **Caution:** Before you enable this API, make sure you've reviewed and agreed to the [Chrome Policy API Terms of Service](http://console.cloud.google.com/tos?id=chrome-policy).\n\n1. Open the [Google Cloud Console](https://console.cloud.google.com/).\n2. At the top, choose your Google Cloud project.\n3. At the top-left, click Menu menu \\\u003e **APIs \\& Services** \\\u003e **Library**.\n4. In the search field, enter \"Chrome\" and press **Enter**.\n5. In the list of search results, click **Chrome Policy API**.\n6. Click **Enable**.\n7. To enable more APIs, repeat steps 2--5.\n\nStep 3: Create credentials\n--------------------------\n\nRequests to the Chrome Policy API can be authenticated as an end user or a robot\nservice account.\n\n### Configure the OAuth consent screen\n\n1. Open the [Google Cloud Console](https://console.cloud.google.com/).\n2. At the top, choose your Google Cloud project.\n3. At the top-left, click Menu menu \\\u003e **APIs \\& Services** \\\u003e **OAuth consent screen**.\n4. Select the user type for your app, then click **Create**.\n5. Complete the app registration form, then click **Save and Continue**.\n6. Click **Add or remove scopes**. A panel appears with a list of scopes for\n each API you've enabled in your Google Cloud project. Add one of the\n following authorization scopes:\n\n - `https://www.googleapis.com/auth/chrome.management.policy`\n - `https://www.googleapis.com/auth/chrome.management.policy.readonly`\n\n The `readonly` scope doesn't allow any mutation operations.\n | **Note:** These scopes are categorized as *Sensitive scopes*. An app verification process is only required for apps used outside of an organization.\n\n### Set up end user or service account authentication\n\nClick an option below for detailed instructions:\n\n#### Option 1: Authenticate as an end user with OAuth 2.0\n\n1. Open the [Google Cloud Console](https://console.cloud.google.com/).\n2. At the top, choose your Google Cloud project.\n3. At the top-left, click Menu menu \\\u003e **APIs \\& Services** \\\u003e **Credentials**.\n4. Click **Create Credentials** \\\u003e **OAuth client ID**.\n5. Follow the steps to create the OAuth 2.0 credentials.\n\n\nNo special setup is required in the Admin console by the organization's Chrome\nadmin for OAuth 2.0 authentication. Users of your app will need to have the\n[required admin role permissions](/chrome/policy/guides/policy-schemas#namespaces)\nassociated with their account and need to agree to the app's OAuth consent\nscreen.\n\n\n**Tip:** You can [test your app in the OAuth Playground](#test-your-app).\n\n#### Option 2: Authenticate as a service account\n\n\nA service account is a special kind of account used by an application, rather\nthan a person. You can use a service account to access data or perform actions\nby the robot account itself, or to access data on behalf of users.\nFor more details, refer to\n[Understanding service accounts](https://cloud.google.com/iam/docs/understanding-service-accounts).\n\n#### Create a service account \\& credentials\n\n1. Open the [Google Cloud Console](https://console.cloud.google.com/).\n2. At the top, choose your Google Cloud project.\n3. At the top-left, click Menu menu \\\u003e **APIs \\& Services** \\\u003e **Credentials**.\n4. Click **Create Credentials** \\\u003e **Service account**.\n5. Enter service account name, then click **Create and continue**.\n6. Optional: Assign roles to your service account to grant access to your Google Cloud project's resources. For more details, refer to [Granting, changing, and revoking access to resources](https://cloud.google.com/iam/docs/granting-changing-revoking-access).\n7. Click **Continue**.\n8. Optional: Enter users or groups that can manage and perform actions with this service account. For more details, refer to [Managing service account impersonation](https://cloud.google.com/iam/docs/impersonating-service-accounts).\n9. Click **Done**. After a few minutes, your new service account appears in the \"Service Accounts\" list. (You might need to refresh the page.)\n10. In the \"Service Accounts\" list, click the service account you created.\n11. Click **Keys** \\\u003e **Add keys** \\\u003e **Create new key**.\n12. Select **JSON** , then click **Create** .\n\n Your new public/private key pair is generated and downloaded to your machine as a new file. This file is the only copy of this key. For information about how to store your key securely, see [Managing service account keys](https://cloud.google.com/iam/docs/understanding-service-accounts#managing_service_account_keys).\n\n#### Authorize the service account in the Admin console\n\n\nIf you choose to authenticate requests as a service account, the\norganization's Chrome administrator needs to perform additional steps in the\nAdmin console to complete the process.\n\n\nThe Chrome admin can either [assign a role to the service account directly](https://support.google.com/a/answer/33325)\nwith the [required admin role permissions](/chrome/policy/guides/policy-schemas#namespaces),\nor the Chrome admin can set up domain-wide delegation so the service account\ncan impersonate users with proper permissions and act on their behalf.\n\n\nTo set up domain-wide delegation for your service account, the Chrome admin\nneeds to follow these steps in the Admin console:\n\n1. Open the [Admin console](https://admin.google.com/).\n2. At the top-left, click Menu menu \\\u003e **Security** \\\u003e **Access and data control** \\\u003e **API controls**.\n3. Click **Manage Domain Wide Delegation**.\n4. Click **Add new**.\n5. In the \"Client ID\" field, paste the client ID associated with your service account. [Learn how to find your service account's client ID.](https://developers.google.com/workspace/guides/create-credentials#optional_set_up_domain-wide_delegation_for_a_service_account)\n6. In the \"OAuth Scopes\" field, enter a comma-delimited list of the scopes required by the service account application. This is the same set of scopes defined when configuring the OAuth consent screen.\n7. Click **Authorize**.\n\nStep 4: Test your app in the OAuth Playground\n---------------------------------------------\n\n1. Open the [Google Cloud Console](https://console.cloud.google.com/).\n2. At the top, choose your Google Cloud project.\n3. At the top-left, click Menu menu \\\u003e **APIs \\& Services** \\\u003e **Credentials**.\n4. Click **Create Credentials** \\\u003e **OAuth client ID**.\n5. Click **Application type** \\\u003e **Web application**.\n6. In the \"Name\" field, type a name for the credential. This name is only shown in the Cloud Console.\n7. For the time of testing, add `https://developers.google.com/oauthplayground` to \"Authorized redirect URIs.\" You can remove this redirect URI from your app when done testing, if needed.\n8. Click **Create** and copy the \"client ID\" and \"client secret\" to your clipboard.\n9. In a new tab, open the [OAuth 2.0 Playground](https://developers.google.com/oauthplayground/).\n10. At the top-right, click OAuth 2.0 configuration settings.\n11. Select **Use your own OAuth credentials** . Then, paste the \"client ID\" and \"client secret\" you copied in step 8 and click **Close**.\n12. At the left, follow the OAuth 2.0 Playground steps:\n - For \"Step 1: Select \\& authorize APIs,\" add `https://www.googleapis.com/auth/chrome.management.policy` and any other needed API scopes, then click **Authorize APIs**.\n - For \"Step 2: Exchange authorization code for tokens,\" you can optionally select **Auto-refresh the token before it expires**.\n - For \"Step 3: Configure request to API,\" enter your Chrome Policy API request URI, modifying the \"HTTP Method\" and other settings, as needed. Example URL request: `https://chromepolicy.googleapis.com/v1/customers/my_customer/policySchemas?filter=chrome.printers`\n\nStep 5: Verify your app is trusted\n----------------------------------\n\nAn organization's admin can mark apps as trusted or blocked in the\nAdmin console. For more details, see [Control which third-party \\& internal apps access Google Workspace data](https://support.google.com/a/answer/7281227#zippy=%2Cmanage-access-to-apps-trusted-limited-or-blocked)."]]