You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google API获取所有品牌账户?

获取Google账户下品牌账户的API方案

Great question! I’ve looked into this exact scenario before, and there is a valid API solution to pull all brand accounts linked to your Google account—here’s how it works:

  • Use the Google People API
    This is the official, supported way to fetch brand account data for the authenticated user. You’ll need to call the people.get endpoint with the personFields=brandAccounts parameter to specifically request brand account information.

  • Required Permissions
    You’ll need to request the profile OAuth scope (or the more specific https://www.googleapis.com/auth/userinfo.profile) during the authorization flow. This ensures your app has access to the user’s profile-associated brand accounts.

  • Quick Code Example
    Here’s a Python snippet to demonstrate the call (assuming you’ve already set up OAuth 2.0 credentials):

    from googleapiclient.discovery import build
    from google.oauth2.credentials import Credentials
    
    # Load your saved OAuth credentials
    creds = Credentials.from_authorized_user_file('token.json')
    people_service = build('people', 'v1', credentials=creds)
    
    # Fetch the user's brand accounts
    response = people_service.people().get(
        resourceName='people/me',
        personFields='brandAccounts'
    ).execute()
    
    # Extract and iterate through brand accounts
    brand_accounts = response.get('brandAccounts', [])
    for account in brand_accounts:
        print(f"Brand Account: {account['displayName']} | ID: {account['metadata']['source']['id']}")
    
  • Key Notes

    • Make sure you’ve enabled the Google People API in your Google Cloud Console project before making calls.
    • The returned data matches what you see on myaccount.google.com/brandaccounts—including display names, account IDs, and account types.
    • For Google Workspace users, you might need additional Admin SDK scopes if managing brand accounts for an organization, but for personal accounts, the People API is all you need.

内容的提问来源于stack exchange,提问作者Jeff I

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:10:26