- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用服务帐户将文件上传到谷歌驱动器,但出现类似错误
(403) Insufficient Permission error
虽然从驱动器中获取文件列表工作正常。
require_once 'google-api-php-client-master/src/Google/autoload.php';
require_once 'google-api-php-client-master/src/Google/Service.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client_secrets.json');
$service_account_name = '251181790499-1en2vs6jjovga1egu15tphm1m7g44m60@developer.gserviceaccount.com';
$key_file_location = 'key.p12'; //key.p12
$key = file_get_contents($key_file_location);;
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
//$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
//$client->setScopes(array('https://www.googleapis.com/auth/drive'));
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array('https://www.googleapis.com/auth/drive'),
$key);
$client->setAssertionCredentials($cred);
$client->setAccessType("offline");
$file = new Google_Service_Drive_DriveFile();
$file->setTitle(uniqid().'.jpg');
$file->setDescription('A test document');
$file->setMimeType('image/jpeg');
$data = file_get_contents('a.jpg');
$service = new Google_Service_Drive($client);
$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => 'image/jpeg',
'uploadType' => 'multipart'
));
print_r($createdFile);
}
else
{
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/googledrive/oauth2callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
我在论坛中查看了类似的问题并尝试了建议,但似乎没有任何效果。
代码有问题吗?
最佳答案
将您的 Google 云端硬盘范围更改为
Google_Service_Drive::DRIVE
在 PHP 中
$client->addScope(Google_Service_Drive::DRIVE);
关于google-drive-api - Google 云端硬盘上传返回 - (403) 权限不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33075595/
是否可以进行 Puppet 设置,在其中使用 JClouds 在云上实例化新虚拟机,然后通过 Puppet 定义和实现其配置(软件堆栈)? 或者 Puppet 的本质是否存在某些固有的因素阻碍其在 A
作者:京东零售 郑炳懿 前言: 当今世界,云计算技术在快速发展,不断为我们带来新的应用场景和解决方案。作为一名前端开发者,了解云技术并掌握如何在前端中应用它们是必不可少的。
我在我们的 iOS 通用应用程序中使用核心数据,并希望用户能够将其数据备份到我们的服务器。因此他们可以使用另一台设备登录并将该数据拉取到该设备。有人对此有什么建议吗?我想在服务器上分析数据,以便与我们
我在 Xcode 的验证过程中收到此错误,这让我抓狂。我花了几个小时试图修复它,但找不到解决方案。 我们拥有正确的分发证书、供应配置文件以及我能想到的与此相关的一切。我已经撤销并重建了我所有的项目,但
今天我对一个项目有了一个非常好的想法,不幸的是存在信息/经验障碍。 我基本上想要的是在云中运行游戏并将图像流式传输给用户。 我知道 ec2 可以选择使用 GPU,但它可能有错误的定价模型来满足我的需求
我是 Cloud Firestore 的新手(我们不都是这样吗?)并且我已经使用 Node.js 中的管理 SDK 向我的数据库添加了一些数据。它显示在控制台上,但在文档下显示“此文档不存在,它不会出
我有一个托管在 s3 存储桶上的静态 html 网站。我已经使用 let's encrypt 生成了一个免费的 ssl 证书,并将其导入到 ACM 中。 certbot --manual --serv
我一直在阅读 Cloudfront 文档,我想确保我的计划是合理的。我有一个后端 API,结构为 EC2 HTTP 服务器,内容经常更新(每秒几次更改)。这是我的理解: 我不应该将此 HTTP 服务器
我是一名优秀的程序员,十分优秀!