使用账号数据
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本教程介绍了如何使用账号数据。借助 My Business Account Management API,您可以执行以下操作:
准备工作
在使用 My Business Account Management API 之前,您需要注册您的应用并获取 OAuth 2.0 凭据。
如需详细了解如何开始使用 Business Profile API,请参阅基本设置。
列出所有账号
要验证与经过身份验证的用户关联的账号,一个好方法是列出其所有账号。使用 accounts.list
API 可列出与某个用户关联的所有账号。
要列出经过身份验证的用户的所有账号,请使用以下命令:
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts
返回特定账号
有时,您只需要查看与经过身份验证的用户的特定账号相关的信息。使用 accounts.get
API 可返回特定账号并查看其他账号详情。
要按名称返回特定账号,请使用以下命令:
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
更新账号
更改账号名称是一项基本的管理任务。使用 accounts.update
API 可更改账号名称。
要按名称更新特定账号,请使用以下命令:
$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
{
"account": {
"accountName": "Anne Droyd"
},
"languageCode": "en",
"validateOnly": "true"
}
限制
- 账号中唯一可修改的字段是
accountName
。传递的其他任何字段都会被忽略。
- 只有
BUSINESS
类型的账号才能采用这种方式进行更新。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[[["\u003cp\u003eThe My Business Account Management API allows you to manage business accounts, including listing all accounts, retrieving specific account details, and updating account names.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you must register your application and obtain OAuth 2.0 credentials as outlined in the basic setup guide.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a list of all accounts associated with an authenticated user or fetch details for a specific account using dedicated API endpoints.\u003c/p\u003e\n"],["\u003cp\u003eUpdating an account is restricted to changing the account name for business type accounts only, with other fields being ignored.\u003c/p\u003e\n"]]],[],null,["# Work with account data\n\n\u003cbr /\u003e\n\nThis tutorial shows you how to work with account data. The My Business Account Management API\nprovides you with the ability to do the following:\n\n- List all accounts.\n- Return a specific account.\n- Update an account.\n\nBefore you begin\n----------------\n\nBefore you use the My Business Account Management API, you need to register your application\nand obtain OAuth 2.0 credentials.\n\nFor details on how to get started with the Business Profile APIs, see\n[Basic setup](/my-business/content/basic-setup).\n\nList all accounts\n-----------------\n\nA great way to validate the accounts associated with an authenticated user is to\nlist all their accounts. Use the [`accounts.list`](/my-business/reference/accountmanagement/rest/v1/accounts/list)\nAPI to list all accounts associated with a user.\n\nTo list all the accounts for an authenticated user, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts\n```\n\nReturn a specific account\n-------------------------\n\nSometimes, you only want to see information about a specific account for an\nauthenticated user. Use the [`accounts.get`](/my-business/reference/accountmanagement/rest/v1/accounts/get)\nAPI to return a specific account and review additional account details.\n\nTo return a specific account by name, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n```\n\nUpdate an account\n-----------------\n\nChanging an account name is a fundamental administrative task. Use the\n[`accounts.update`](/my-business/reference/accountmanagement/rest/v1/accounts/patch) API to alter\nthe account name.\n\nTo update a specific account by name, use the following:\nHTTP \n\n```bash\n$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n\n{\n \"account\": {\n \"accountName\": \"Anne Droyd\"\n },\n \"languageCode\": \"en\",\n \"validateOnly\": \"true\"\n}\n```\n\n### Restrictions\n\n- The only editable field for an account is `accountName`. Any other fields passed are ignored.\n- Only accounts of `BUSINESS` type can be updated in this manner."]]