“错误”:“ invalid_grant”,“错误说明”:“错误请求”

时间:2020-04-13 21:49:54

标签: php google-api-php-client

我对Doubleclick出价管理器API进行身份验证时出错。错误消息是

{ "error": "invalid_grant", "error_description": "Bad Request" }

这是我的代码,我在PHP中有它。任何帮助将不胜感激

`


    $code = $_GET['code'];
    static::$Request = curl_init();
    curl_setopt(static::$Request,CURLOPT_URL,"https://www.googleapis.com/oauth2/v4/token");
    curl_setopt(static::$Request, CURLOPT_POST, 1 );
    curl_setopt(static::$Request,CURLOPT_POSTFIELDS,"client_id=".urlencode(static::$client->getClientId())."&client_secret=".urlencode(static::$client->getClientSecret())."&code=".$code."&grant_type=authorization_code&redirect_uri=".urlencode('http://localhost/dv360.omdata.co/index.php'));
    curl_setopt(static::$Request, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt(static::$Request, CURLOPT_RETURNTRANSFER, true);
    static::$Response = curl_exec(static::$Request);
    curl_close(static::$Request);
    print_r(static::$Response);

`

0 个答案:

没有答案