【问题标题】:AuthorizationError.USER_PERMISSION_DENIED when testing against test MCC account (Creating Account)针对测试 MCC 帐户(创建帐户)进行测试时的 AuthorizationError.USER_PERMISSION_DENIED
【发布时间】:2015-08-02 10:55:23
【问题描述】:

我正在尝试测试 AdWords API 以了解其功能。 我不知道为什么我不断收到 AuthorizationError.USER_PERMISSION_DENIED 错误。

例如,我尝试在 AdWords 提供的 Java 客户端库示例中运行 CreateAccount.java。

这是我的步骤: 1.我创建了一个生产MCC帐户,然后得到一个“开发者令牌” 2. 我创建了一个测试 MCC 帐户,然后从控制台获取一个新的“客户端 ID”和“客户端密码”。从这里我得到了“刷新令牌” 我将“开发者令牌”(来自上面的第 1 步)、“客户端 ID”和“客户端密码”放入 ads.properties。 3. 对于 ads.properties 中的“用户代理”值,我输入了“项目 ID”的名称。 4. 对于 ads.properties 中的“客户客户 ID”值,我放置了测试 MCC 帐户客户 ID。 5. 然后我尝试在下面运行它并得到 AuthorizationError.USER_PERMISSION_DENIED 错误。

我想知道是否有任何步骤我遗漏或做错了。 提前感谢您的帮助。

下面是我尝试运行的代码。在这一行抛出异常:

ManagedCustomerReturnValue result = managedCustomerService.mutate(operations);

这是完整的 sn-p(来自 AdWords 代码示例)

// Generate a refreshable OAuth2 credential similar to a ClientLogin token
// and can be used in place of a service account.
Credential oAuth2Credential = new OfflineCredentials.Builder()
    .forApi(Api.ADWORDS)
    .fromFile()
    .build()
    .generateCredential();


// Construct an AdWordsSession.
AdWordsSession session = new AdWordsSession.Builder()
    .fromFile()
    .withOAuth2Credential(oAuth2Credential)
    .build();


AdWordsServices adWordsServices = new AdWordsServices();

// Get the CampaignService.
ManagedCustomerServiceInterface managedCustomerService =
    adWordsServices.get(session, ManagedCustomerServiceInterface.class);


// Create account.
ManagedCustomer customer = new ManagedCustomer();
customer.setName("Customer created with ManagedCustomerService on " + new DateTime());
customer.setCurrencyCode("EUR");
customer.setDateTimeZone("Europe/London");


// Create operations.
ManagedCustomerOperation operation = new ManagedCustomerOperation();
operation.setOperand(customer);
operation.setOperator(Operator.ADD);


ManagedCustomerOperation[] operations = new ManagedCustomerOperation[ {operation};


// Add account.
ManagedCustomerReturnValue result = managedCustomerService.mutate(operations);


// Display accounts.
for (ManagedCustomer customerResult : result.getValue()) {
  System.out.println("Account with customer ID \"" + customerResult.getCustomerId()
      + "\" was created.");
}

【问题讨论】:

    标签: java google-ads-api


    【解决方案1】:

    我想你已经遵循了这些步骤:

    1] 在 Google Developer Console 上创建了一个应用,并获得了 ads.properties 的这些值: api.adwords.clientId 和 api.adwords.clientSecret

    2] 然后,您在获得 developerToken 的地方创建生产 MCC 帐户。将其放入 ads.properties。

    3] 然后创建 MCC 测试帐户,其中您有主 mcc 帐户 adwords id,您可能已将其放入 ads.properties。

    4] 然后,您使用从 google 团队提供的示例运行 GetRefreshToken.java 获得刷新令牌。(在此处重新检查,运行 GetRefreshToken.java 后,您将在 java 输出控制台上获得的 url 发布到浏览器并通过登录授予此应用程序的权限进入您的测试 mcc gmail 帐户。然后您会在浏览器窗口中获得一些字符串。将该字符串作为输入复制到 Java 输出控制台并按 Enter。在此阶段,您将获得真正的 refreshToken 作为 Java 输出控制台中的输出,将其复制到您的广告.properties)。

    5] 将此 set useragent 设置为一些随机字符串后。

    6] 然后从google团队提供的示例中运行java程序CreateAccount.java。

    7] 这应该可以工作。

    大多数时候人们在生成refreshToken时会犯错误,请按照“GetRefreshToken.java”的流程逐步进行。

    【讨论】:

    • 谢谢!有用。我错过了这部分:“..通过登录到您的测试 mcc gmail 帐户来授予此应用程序的权限..”。我发现我使用 prod mcc gmail 帐户登录。
    【解决方案2】:

    确保您授予了正确的 MMC 权限。 如果要查看测试客户端数据,则必须在登录 TEST MCC 时复制由 GetRefreshToken 生成的链接。如果你想查看产品。客户端数据,您在登录产品时复制由 GetRefreshToken 生成的链接。中冶。

    这里是完整的文档: https://developers.google.com/adwords/api/docs/test-accounts

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-05
      相关资源
      最近更新 更多