Google 비즈니스 프로필 연결

Google 비즈니스 위치 그룹은 위치 공유 폴더와 유사합니다. 비즈니스 위치 그룹을 사용하면 여러 사용자와 공동으로 안전하게 위치를 관리할 수 있습니다. 자세한 내용은 비즈니스 위치 그룹 정보를 참고하세요.

오프라인 인벤토리를 업로드하기 전에 판매자 센터 계정에서 담당할 비즈니스 위치 그룹을 지정합니다. Merchant API를 사용하여 비즈니스 프로필에서 자격요건을 충족하는 비즈니스 위치 그룹의 목록을 가져올 수 있지만 액세스하려면 먼저 계정을 비즈니스 프로필에 연결해야 합니다.

비즈니스 프로필 액세스 권한 요청하기

비즈니스 프로필에 액세스하려면 gbpAccounts.LinkGbpAccount 메서드를 사용하세요.

POST https://merchantapi.googleapis.com/accounts/v1beta/accounts/<var>ACCOUNT_ID</var>/gbpAccounts:linkGbpAccount

{
  "gbpEmail": "admin@example.com",
}

다음을 바꿉니다.

  • ACCOUNT_ID: 판매자 센터 계정의 고유 식별자
  • GBP_EMAIL: 비즈니스 프로필 관리자의 이메일

이 메서드를 호출하면 서비스는 지정된 관리자에게 액세스 요청을 수락하거나 거부하도록 요청하는 이메일을 보냅니다. 관리자가 7일 이내에 응답하지 않으면 요청이 자동으로 만료됩니다.

사용 가능한 비즈니스 위치 그룹 나열

관리자가 요청을 승인하면 gbpAccounts.List 메서드를 사용하여 사용 가능한 비즈니스 그룹을 확인할 수 있습니다.

다음은 샘플 요청과 성공적인 응답입니다.

GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/<var>ACCOUNT_ID</var>/gbpAccounts

Response:
200 OK
{
  "gbpAccounts": [
    {
      "name": "accounts/<var>ACCOUNT</var>/gbpAccounts/12345",
      "gbpAccountId": 12345,
      "type": USER,
      "gbpAccountName": "admin@example.com",
      "listingCount": 15
    }, {
      "name": "accounts/<var>ACCOUNT</var>/gbpAccounts/67890",
      "gbpAccountId": 67890,
      "type": BUSINESS_ACCOUNT,
      "gbpAccountName": "Google My Business Account",
      "listingCount": 23
    }
  ],
  "nextPageToken": 50
}

이 코드 샘플을 활용하여 요건을 충족하는 모든 비즈니스 그룹을 가져올 수 있습니다.

package shopping.merchant.samples.accounts.v1beta;

// [START merchantapi_list_gbp_accounts]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.AccountName;
import com.google.shopping.merchant.accounts.v1beta.GbpAccount;
import com.google.shopping.merchant.accounts.v1beta.GbpAccountsServiceClient;
import com.google.shopping.merchant.accounts.v1beta.GbpAccountsServiceClient.ListGbpAccountsPagedResponse;
import com.google.shopping.merchant.accounts.v1beta.GbpAccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1beta.ListGbpAccountsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/**
 *   This class demonstrates how to get the list of GBP accounts for a given Merchant Center account
 */
public class ListGbpAccountsSample {

  public static void listGbpAccounts(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the retrieved credentials.
    GbpAccountsServiceSettings gbpAccountsServiceSettings =
        GbpAccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String accountId = config.getAccountId().toString();
    // Creates parent to identify the omnichannelSetting from which to list all Lfp Providers.
    String parent = AccountName.newBuilder().setAccount(accountId).build().toString();

    // Calls the API and catches and prints any network failures/errors.
    try (GbpAccountsServiceClient gbpAccountsServiceClient =
        GbpAccountsServiceClient.create(gbpAccountsServiceSettings)) {
      ListGbpAccountsRequest request =
          ListGbpAccountsRequest.newBuilder().setParent(parent).build();

      System.out.println("Sending list GBP accounts request:");
      ListGbpAccountsPagedResponse response = gbpAccountsServiceClient.listGbpAccounts(request);

      int count = 0;

      // Iterates over all the entries in the response.
      for (GbpAccount gbpAccount : response.iterateAll()) {
        System.out.println(gbpAccount);
        count++;
      }
      System.out.println(String.format("The following count of elements were returned: %d", count));
    } catch (Exception e) {
      System.out.println("An error has occurred: ");
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    listGbpAccounts(config);
  }
}
// [END merchantapi_list_gbp_accounts]

판매자 센터 계정의 비즈니스 위치 그룹 지정

사용 가능한 비즈니스 위치 그룹 목록에서 비즈니스 위치 그룹을 판매자 센터 계정과 연결할 수 있습니다. 예를 들어 GBP 계정 ID 12345 (이전 단계에서 반환됨)가 있는 비즈니스 그룹을 선택하려면 AccountServices.proposeAccountService를 사용하면 됩니다.

POST
https://merchantapi.googleapis.com/accounts/v1beta/accounts/<var>ACCOUNT_ID</var>/services:propose
{
  provider: "providers/GOOGLE_BUSINESS_PROFILE",
  account_service: {
    external_account_id: "12345",
    local_listing_management {}
  }
}

provider 필드는 providers/GOOGLE_BUSINESS_PROFILE여야 합니다. 요청에 빈 LocalListingManagement 필드를 설정해야 합니다.

제품 및 인벤토리 데이터 제출

이제 판매자 센터 계정을 비즈니스 위치 그룹과 연결했으므로 제품 및 오프라인 판매점 인벤토리 데이터를 업로드할 수 있습니다. 자세한 내용은 다음을 참조하세요.