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.
Để sử dụng API Quản lý máy in Chrome, bạn cần bật API và tạo thông tin xác thực OAuth 2.0 của ứng dụng. Sau đó, quản trị viên Chrome cần cấp cho tập lệnh của bạn quyền truy cập vào tài khoản cần thiết để quản lý máy in.
Quản trị viên có thể tuỳ ý chặn hoặc tin tưởng các ứng dụng được phát triển để quản lý máy in cho tài khoản của họ.
Hãy làm theo các bước bên dưới để thiết lập mọi thứ cần thiết cho quyền truy cập API. Các hướng dẫn này giả định rằng bạn đã thiết lập màn hình xin phép bằng OAuth cho một ứng dụng và thiết lập tài khoản dịch vụ. Nếu không, hãy xem phần Định cấu hình sự đồng ý OAuth và Tạo tài khoản dịch vụ trước khi tiếp tục.
Bật API và tạo thông tin xác thực
Bật API.
API bạn đang bật là "SDK dành cho quản trị viên".
Trước khi sử dụng, tài khoản dịch vụ của bạn cần được cấp các đặc quyền quản trị thích hợp. Việc này phải do quản trị viên thực hiện cho khách hàng liên kết với máy in hoặc máy chủ in mà tài khoản dịch vụ quản lý.
Cách 1: Bật tính năng uỷ quyền trên toàn miền cho tài khoản dịch vụ
Tính năng uỷ quyền trên toàn miền cho phép tài khoản dịch vụ mạo danh một quản trị viên có các đặc quyền thích hợp để quản lý máy in và máy chủ in.
Phạm vi OAuth mà bạn cần cho bước này là https://www.googleapis.com/auth/admin.chrome.printers.
Cách 2: Cấp đặc quyền vai trò quản trị viên cho tài khoản dịch vụ
Nếu muốn giới hạn các đặc quyền của tài khoản dịch vụ trên miền, bạn có thể chỉ định cho tài khoản đó một vai trò có đặc quyền chỉ quản lý máy in. Để tìm hiểu thêm về cách sử dụng vai trò để kiểm soát quyền truy cập, hãy xem phần Quản lý vai trò.
Ở trên cùng bên trái, hãy nhấp vào biểu tượng Trình đơn menu >
Bảo mật>Quyền truy cập và kiểm soát dữ liệu>Chế độ kiểm soát API.
Trong mục "Kiểm soát quyền truy cập vào ứng dụng", hãy nhấp vào Quản lý quyền truy cập của ứng dụng bên thứ ba.
Trong phần "Ứng dụng đã kết nối":
Nếu bạn không thấy ứng dụng đó trong danh sách, hãy nhấp vào Định cấu hình ứng dụng mới. Sau đó, hãy làm theo hướng dẫn trên màn hình.
Nếu bạn thấy ứng dụng đó trong danh sách, hãy nhấp vào tên ứng dụng. Sau đó, hãy chọn bị chặn hoặc đáng tin cậy trong phần "Quyền truy cập vào ứng dụng" rồi nhấp vào Lưu.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-03-25 UTC."],[],[],null,["# Get started\n\nTo use the Chrome Printer Management API, you need to enable the API and create the app's OAuth\n2.0 credentials. Then a\n[Chrome administrator](https://support.google.com/a/answer/6208960)\nneeds to grant your script the necessary account access to manage printers.\nAdmins can optionally block or trust apps developed to manage printers\nfor their account.\n\nFollow the steps below to set up everything required for API access. These\ninstructions assume you already have an app with its OAuth consent screen set\nup, and a service account set up. If that's not the case, see\n[Configure OAuth consent](/workspace/guides/configure-oauth-consent) and\n[Create a service account](/workspace/guides/create-credentials#create_a_service_account)\nbefore continuing.\n| **Note:** Only service accounts can access the Chrome Printer Management API at this time.\n\nEnable API and create credentials\n---------------------------------\n\n1. [Enable the API](/workspace/guides/enable-apis). The API you are enabling is \"Admin SDK.\"\n2. [Create OAuth 2.0 credentials](/workspace/guides/create-credentials#create_credentials_for_a_service_account) for your service account. Store the downloaded JSON file in a secure location.\n\nEnable service account access\n-----------------------------\n\nBefore use, your service account needs to be granted proper admin\nprivileges. This must be done by an administrator for the customer\nassociated with the printers or print servers that the service account manages.\n\n### Option 1: Enable domain-wide delegation for the service account\n\nDomain-wide delegation lets the service account impersonate an admin who\nhas the proper privileges to manage printers and print servers.\n\n[Enable domain-wide delegation](/workspace/guides/create-credentials#optional_set_up_domain-wide_delegation_for_a_service_account)\n\nThe OAuth scope you need for this step is\n`https://www.googleapis.com/auth/admin.chrome.printers`.\n| **Note:** Depending on your app, you might need to enter additional scopes. For example, you might need to list scopes for the [Chrome Policy API](/chrome/policy)or the [Directory API](/workspace/admin/directory) (to view or manage organizational units).\n\n### Option 2: Grant admin role privileges to the service account\n\nIf you prefer to limit the service account's privileges on the domain, you can\nassign it a role with privileges to only manage printers. To learn more about\nusing roles for access control, see\n[Manage roles](/workspace/admin/directory/v1/guides/manage-roles).\n\n1. As an administrator, sign in to the [Admin console](https://admin.google.com/).\n2. At the top left of the page, click menu \\\u003e **Account** \\\u003e **Admin\n roles**.\n3. Select an existing role with the privilege below, or create a new role and\n add this privilege:\n\n `Services \u003e ChromeOS \u003e Settings \u003e Manage Printers`\n4. Assign this role to the service account email address.\n\nBlock or trust a printer management app\n---------------------------------------\n\nApps are trusted by default, but an administrator can choose to block or trust\nspecific apps for their account.\n\n1. As an administrator, sign in to 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. In the \"App access control\" section, click **Manage Third-party App Access**.\n4. In the \"Connected apps\" section:\n - If you don't see the app listed, click **Configure new app**. Then, follow the on-screen instructions.\n - If you see the app listed, click the app name. Then, select blocked or trusted under \"App Access\" and click **Save**."]]