Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 谷歌云打印“;403所需的用户凭据“;_Php_Guzzle_Google Cloud Print - Fatal编程技术网

Php 谷歌云打印“;403所需的用户凭据“;

Php 谷歌云打印“;403所需的用户凭据“;,php,guzzle,google-cloud-print,Php,Guzzle,Google Cloud Print,我看到过一些帖子和我面临的问题是一样的,但是,即使其他帖子提出了一些改变,我也无法让它发挥作用 因此,当我使用其他google API失败时,我通常会收到一条(信息性的)错误代码和/或消息。但在这种情况下不是这样 使用PHP和Guzzle,我尝试完成这个请求 $headers = [ RequestOptions::HEADERS => [ 'Authorization' => 'Bearer ' . $oResponse->access

我看到过一些帖子和我面临的问题是一样的,但是,即使其他帖子提出了一些改变,我也无法让它发挥作用

因此,当我使用其他google API失败时,我通常会收到一条(信息性的)错误代码和/或消息。但在这种情况下不是这样

使用PHP和Guzzle,我尝试完成这个请求

$headers = [
        RequestOptions::HEADERS => [
            'Authorization' => 'Bearer ' . $oResponse->access_token,
            'X-CloudPrint-Proxy' => 'Google-JS',
            'Content-Type' => 'application/x-www-form-urlencoded',
            'Accept-Charset' => 'utf-8',
        ]
    ];

    $getPrinters = $client
        ->post('https://www.google.com/cloudprint/search?output=json', $headers)
        ->getBody()
        ->getContents();
但我明白了:

客户端错误:`POSThttps://www.google.com/cloudprint/search?output=json`导致“需要403个用户凭据”响应:需要用户凭据用户凭据(截断…)

我尝试了不同类型的头,但它们都返回相同的结果

$oResponse->access\u token
来自此部件(有效)

而且我也没有发现任何有用的东西。但是,也许我只是误解了它

我还尝试了其他HTTP请求客户端,比如和“raw curl”。但结果还是一样

所以。下一步我能做什么


干杯

确保通过OAuth获得访问令牌

也改为

检查:

/搜索仅支持以下参数:
q、 键入、连接状态、使用cdd、额外字段

我想这是在询问您的用户名和密码<代码>user@domain.com:密码样式凭据。尝试使用您用来登录控制台的电子邮件地址和密码。它有一个Python示例,但它给出了一个如何使用以及使用什么凭据的示例。
    $response = $client->post('https://www.googleapis.com/oauth2/v4/token', [
        RequestOptions::FORM_PARAMS => [
            'refresh_token' => 'valid token',
            'client_id' => 'xxxxx',
            'client_secret' => 'xxxxx',
            'grant_type' => 'refresh_token'
        ],
        RequestOptions::HEADERS => [
            'Content-Type' => 'application/x-www-form-urlencoded'
        ]
    ])->getBody()->getContents();

    $oResponse = json_decode($response);