【问题标题】:AdSense Management API - Missing required parameter: redirect_uri With Service AccountAdSense 管理 API - 缺少必需参数:redirect_uri 与服务帐户
【发布时间】:2015-05-01 12:43:40
【问题描述】:

尝试连接 AdSense 管理 API 示例时出现以下错误:

缺少必需参数:redirect_uri

我正在使用服务帐户,因为我的服务器处理 adSense api 之间的所有交互。用户不参与。这是我的 PHP 代码:

$client = new Google_Client();
$client->setApplicationName("PeopleHelpingPeople"); // name of your app

// set assertion credentials
$client->setAssertionCredentials(
  new Google_Auth_AssertionCredentials(
    "...", 
array('https://www.googleapis.com/auth/analytics.readonly'),
file_get_contents('client_data.json')  // keyfile you downloaded
));
$client->setScopes(array(
'https://www.googleapis.com/auth/analytics.readonly'
));
$client->setClientId("...");           // from API console
$client->setAccessType('offline_access');  // this may be unnecessary?

// Create service.
$service = new Google_Service_AdSense($client);

为什么会出现此错误?

【问题讨论】:

    标签: php google-oauth adsense-api


    【解决方案1】:

    如果您尝试使用开发者控制台中的 ServiceAccount,即为您提供 p12 文件的那种帐户,则这些帐户不适用于 Adsense。

    看看这个页面上的注释https://developers.google.com/adsense/management/getting_started

    $client->setRedirectUri() 可能会让你克服这个错误,但它不会解决你的最终问题

    【讨论】:

      猜你喜欢
      • 2016-04-14
      • 2015-01-31
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 2012-06-27
      • 1970-01-01
      • 2013-09-02
      • 2014-11-30
      相关资源
      最近更新 更多