Di chuyển hoạt động quản lý người dùng và quyền truy cập
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.
Trong Content API for Shopping, bạn quản lý người dùng và quyền truy cập của họ bằng một trường trong tài nguyên Account
. Merchant API thay thế tài nguyên này bằng tài nguyên chuyên dụng có tên là User
và các phương thức tương ứng (create, delete, get, list, path). Để biết thêm thông tin, hãy xem bài viết Kiểm soát quyền truy cập vào tài khoản của bạn.
Những điểm khác biệt chính
So với Content API for Shopping, Merchant API mang lại những lợi ích sau đây cho việc quản lý người dùng:
- Tài nguyên chuyên dụng: Cách này giúp bạn kiểm soát chi tiết và trực tiếp hơn đối với những người có thể truy cập vào tài khoản Merchant Center của bạn và những việc họ có thể làm.
- Tên tài nguyên RESTful: Trong Merchant API, hãy xác định tài nguyên
User
bằng tên tài nguyên đầy đủ, ví dụ: accounts/12345/users/example@example.com
.
me
alias: Bạn có thể dùng bí danh me
thay cho địa chỉ email trong tên tài nguyên để tham chiếu đến người dùng đã xác thực, ví dụ: accounts/12345/users/me
.
- Quyền truy cập hợp nhất: Merchant API hợp nhất các trường truy cập boolean từ Content API (ví dụ:
admin
, reportingManager
) thành một trường access_rights
duy nhất, có thể lặp lại.
- Mời và xác minh người dùng: Merchant API giới thiệu trạng thái người dùng rõ ràng (
PENDING
hoặc VERIFIED
). Khi bạn tạo một người dùng mới, họ sẽ ở trạng thái PENDING
cho đến khi chấp nhận lời mời. Điều này giúp API hiển thị trạng thái của người dùng, điều mà Content API for Shopping không có.
Thêm
## Yêu cầu
Merchant API sử dụng các URL yêu cầu sau để quản lý người dùng:
GET /accounts/v1/accounts/{account}/users/{email}
GET /accounts/v1/accounts/{account}/users
POST /accounts/v1/accounts/{account}/users
PATCH /accounts/v1/accounts/{account}/users/{email}
DELETE /accounts/v1/accounts/{account}/users/{email}
Bảng sau đây so sánh các URL yêu cầu giữa Content API for Shopping và Merchant API.
Nội dung mô tả yêu cầu |
Content API for Shopping |
Merchant API |
Lấy người dùng cho một tài khoản |
GET {api_version}/{merchantId}/accounts/{accountId} |
GET {api_version}/accounts/{account}/users |
Tạo người dùng |
PATCH {api_version}/{merchantId}/accounts/{accountId} |
POST {api_version}/accounts/{account}/users |
Cập nhật người dùng |
PATCH {api_version}/{merchantId}/accounts/{accountId} |
PATCH {api_version}/accounts/{account}/users/{email} |
Xóa người dùng |
PATCH {api_version}/{merchantId}/accounts/{accountId} |
DELETE {api_version}/accounts/{account}/users/{email} |
Giá trị nhận dạng
Bảng sau đây so sánh các giá trị nhận dạng được dùng trong yêu cầu giữa Content API for Shopping và Merchant API.
Thông tin mô tả về giá trị nhận dạng |
Content API for Shopping |
Merchant API |
Giá trị nhận dạng tài khoản |
accountId |
account tại accounts/{account} |
Giá trị nhận dạng người dùng |
email_address trong đối tượng AccountUser |
email tại accounts/{account}/users/{email} |
Phương thức
Bảng sau đây so sánh các phương thức giữa Content API for Shopping và Merchant API.
Content API for Shopping |
Merchant API |
Phạm vi cung cấp và lưu ý |
accounts.update |
users.create |
Tạo một người dùng mới cho tài khoản. |
accounts.get |
users.get |
Truy xuất một người dùng duy nhất. |
accounts.get |
users.list |
Liệt kê tất cả người dùng của một tài khoản. |
accounts.update |
users.update |
Cập nhật quyền truy cập của người dùng. |
accounts.update |
users.delete |
Xoá một người dùng khỏi tài khoản. |
Thông tin chi tiết về các thay đổi đối với trường
Cập nhật cách sử dụng các trường như sau:
Content API for Shopping |
Merchant API |
Mô tả |
users (lặp lại AccountUser ) |
users (lặp lại User ) |
Tài nguyên User hiện là một tài nguyên cấp cao nhất có dịch vụ riêng. |
AccountUser.email_address |
CreateUserRequest.user_id và một phần của User.name |
Địa chỉ email của người dùng hiện là một phần của tên tài nguyên. Hãy chỉ định giá trị này trong trường user_id trong quá trình tạo. |
AccountUser.admin |
access_rights: "ADMIN" |
Merchant API thay thế trường boolean admin bằng giá trị ADMIN trong enum access_rights . |
AccountUser.order_manager , AccountUser.payments_manager , AccountUser.payments_analyst |
access_rights: "STANDARD" |
Merchant API thay thế các vai trò này bằng quyền truy cập STANDARD . |
AccountUser.reporting_manager |
access_rights: "PERFORMANCE_REPORTING" |
Vai trò reporting_manager hiện là quyền truy cập PERFORMANCE_REPORTING . |
AccountUser.read_only |
access_rights: "READ_ONLY" |
Vai trò read_only hiện là quyền truy cập READ_ONLY . |
Không có |
User.name |
Chứa tên tài nguyên đầy đủ của người dùng, ví dụ: accounts/{account}/users/{email} . |
Không có |
User.state |
Cho biết trạng thái của lời mời gửi cho người dùng, có thể là PENDING hoặc VERIFIED . |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-08 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-08 UTC."],[],[],null,["# Migrate user and access management\n\nIn Content API for Shopping, you managed users and their access rights with a\nfield in the `Account` resource. Merchant API replaces this with the dedicated\nresource named\n[`User`](/merchant/api/reference/rest/accounts_v1/accounts.users) and\ncorresponding methods (create, delete, get, list, path). For more information,\nsee [Control access to your\naccount](/merchant/api/guides/accounts/control-access).\n\nKey differences\n---------------\n\nCompared to Content API for Shopping, Merchant API offers the following\nadvantages for user management:\n\n- **Dedicated resource**: This provides a more granular and direct way to control who can access your Merchant Center account and what they can do.\n- **RESTful resource names** : In Merchant API, identify `User` resources by a full resource name, for example, `accounts/12345/users/example@example.com`.\n- **`me` alias** : You can use the alias `me` in place of an email address in the resource name to refer to the authenticated user, for example, `accounts/12345/users/me`.\n- **Consolidated access rights** : Merchant API consolidates boolean access fields from Content API (for example, `admin`, `reportingManager`) into a single, repeatable`access_rights` field.\n- **User invitation and verification** : Merchant API introduces an explicit user state (`PENDING` or `VERIFIED`). When you create a new user, they are in a `PENDING` state until they accept the invitation. This provides API visibility into the user's status, which was not available in the Content API for Shopping. Add ## Requests\n\nMerchant API uses the following request URLs to manage users:\n\n- `GET /accounts/v1/accounts/{account}/users/{email}`\n- `GET /accounts/v1/accounts/{account}/users`\n- `POST /accounts/v1/accounts/{account}/users`\n- `PATCH /accounts/v1/accounts/{account}/users/{email}`\n- `DELETE /accounts/v1/accounts/{account}/users/{email}`\n\nThe following table compares the request URLs between the Content API for\nShopping and Merchant API.\n\n| Request description | Content API for Shopping | Merchant API |\n|--------------------------|---------------------------------------------------------|---------------------------------------------------------|\n| Get users for an account | `GET {api_version}/{merchantId}/accounts/{accountId}` | `GET {api_version}/accounts/{account}/users` |\n| Create a user | `PATCH {api_version}/{merchantId}/accounts/{accountId}` | `POST {api_version}/accounts/{account}/users` |\n| Update a user | `PATCH {api_version}/{merchantId}/accounts/{accountId}` | `PATCH {api_version}/accounts/{account}/users/{email}` |\n| Delete a user | `PATCH {api_version}/{merchantId}/accounts/{accountId}` | `DELETE {api_version}/accounts/{account}/users/{email}` |\n\nIdentifiers\n-----------\n\nThe following table compares the identifiers used in requests between the\nContent API for Shopping and Merchant API.\n\n| Identifier description | Content API for Shopping | Merchant API |\n|------------------------|-------------------------------------------------|-----------------------------------------------|\n| Account identifier | `accountId` | `account` in `accounts/{account}` |\n| User identifier | `email_address` within the `AccountUser` object | `email` in `accounts/{account}/users/{email}` |\n\nMethods\n-------\n\nThe following table compares the methods between the Content API for Shopping\nand Merchant API.\n\n| Content API for Shopping | Merchant API | Availability \\& notes |\n|--------------------------|----------------------------------------------------------------------------------|------------------------------------|\n| `accounts.update` | [`users.create`](/merchant/api/reference/rest/accounts_v1/accounts.users/create) | Creates a new user for an account. |\n| `accounts.get` | [`users.get`](/merchant/api/reference/rest/accounts_v1/accounts.users/get) | Retrieves a single user. |\n| `accounts.get` | [`users.list`](/merchant/api/reference/rest/accounts_v1/accounts.users/list) | Lists all users for an account. |\n| `accounts.update` | [`users.update`](/merchant/api/reference/rest/accounts_v1/accounts.users/update) | Updates a user's access rights. |\n| `accounts.update` | [`users.delete`](/merchant/api/reference/rest/accounts_v1/accounts.users/delete) | Deletes a user from an account. |\n\nDetailed field changes\n----------------------\n\nUpdate your use of fields as follows:\n\n| Content API for Shopping | Merchant API | Description |\n|---------------------------------------------------------------------------------------------|-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|\n| `users` (repeated `AccountUser`) | `users` (repeated `User`) | The `User` resource is now a top-level resource with its own service. |\n| `AccountUser.email_address` | `CreateUserRequest.user_id` and part of `User.name` | The user's email address is now part of the resource name. Specify it in the `user_id` field during creation. |\n| `AccountUser.admin` | `access_rights: \"ADMIN\"` | Merchant API replaces the boolean `admin` field by the `ADMIN` value in the `access_rights` enum. |\n| `AccountUser.order_manager`, `AccountUser.payments_manager`, `AccountUser.payments_analyst` | `access_rights: \"STANDARD\"` | Merchant API replaces these roles to `STANDARD` access right. |\n| `AccountUser.reporting_manager` | `access_rights: \"PERFORMANCE_REPORTING\"` | The `reporting_manager` role is now the `PERFORMANCE_REPORTING` access right. |\n| `AccountUser.read_only` | `access_rights: \"READ_ONLY\"` | The `read_only` role is now the `READ_ONLY` access right. |\n| Not available | `User.name` | Contains the full resource name of the user, for example, `accounts/{account}/users/{email}`. |\n| Not available | `User.state` | Indicates the status of the user's invitation, either `PENDING` or `VERIFIED`. |"]]