GoogleSheetAPI php curl获取请求

GoogleSheetAPI php curl获取请求,php,curl,oauth,google-api,google-sheets-api,Php,Curl,Oauth,Google Api,Google Sheets Api,我正在使用GoogleOAuthV2 HTTP请求来获取访问toke,它工作正常,我正在获取令牌,但是当使用令牌访问电子表格时,我得到一个403错误 这是我正在使用的请求代码 $get = 'https://sheets.googleapis.com/v4/spreadsheets/1bHKgQLgqB4PfjRUVPkYk5_L7aQOtZGOkhJbr_RFxQQY?access_token='.$access_token; $ch = curl_init(); curl_setop

我正在使用GoogleOAuthV2 HTTP请求来获取访问toke,它工作正常,我正在获取令牌,但是当使用令牌访问电子表格时,我得到一个403错误

这是我正在使用的请求代码

$get = 'https://sheets.googleapis.com/v4/spreadsheets/1bHKgQLgqB4PfjRUVPkYk5_L7aQOtZGOkhJbr_RFxQQY?access_token='.$access_token;

$ch = curl_init();  

curl_setopt($ch,CURLOPT_URL,$get);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false); 
$output = curl_exec($ch);
curl_close($ch);

var_dump($output);
这是带有标题的返回

HTTP/1.1 403 Forbidden
Vary: X-Origin
Vary: Referer
Content-Type: application/json; charset=UTF-8
Date: Tue, 15 Nov 2016 13:13:09 GMT
Server: ESF
Cache-Control: private
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34"
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Transfer-Encoding: chunked

{
  "error": {
  "code": 403,
  "message": "The caller does not have permission",
  "status": "PERMISSION_DENIED"
  }
}
我很想把这张表公之于众,但这对错误没有影响。API控制台上也没有显示该错误

以下是我正在使用的范围:

{
   "iss":"dev-537@mortgagetest-149109.iam.gserviceaccount.com",
   "scope":"https://www.googleapis.com/auth/drive    
    https://www.googleapis.com/auth/drive.readonly 
    https://www.googleapis.com/auth/spreadsheets 
    https://www.googleapis.com/auth/spreadsheets.readonly",
   "aud":"https://accounts.google.com/o/oauth2/token",
   "exp":'.($time+3600).',
   "iat":'.$time.'
}
我做错了什么?

解决了问题

我试图访问的工作表需要与我的客户ID(电子邮件地址)共享 右键单击google drive中的工作表并与电子邮件地址共享


为有相同问题的人发布此消息

看起来您正在验证的用户没有访问该工作表的权限。还要确保使用了正确的作用域对用户进行身份验证。我已经在API控制台中打开了它。是否还有其他地方需要为该用户启用工作表?