我要做的就是从网站上阅读Google电子表格.我已阅读并重新阅读Google Drive API文档以及Stack Overflow上的所有Google Drive PHP,但我仍无法访问终端区域.
这就是我所做的:
<?php
session_start();
require_once 'lib/gapi/Google_Client.php';
require_once 'lib/gapi/contrib/Google_DriveService.php';
define( 'GDRIVE_CLIENT_ID', '<API Console - API Access - Client ID>' );
define( 'GDRIVE_CLIENT_SECRET', '<API Console - API Access - Client secret>' );
define( 'GDRIVE_REDIRECT_URIS', '<API Console - API Access - Redirect URIs>' );
define( 'GDRIVE_SCOPE_01', 'h t t p s://www.googleapis.com/auth/drive' );
define( 'GDRIVE_SCOPE_02', 'h t t p s://www.googleapis.com/auth/drive.apps.readonly' );
define( 'GDRIVE_SCOPE_03', 'h t t p …Run Code Online (Sandbox Code Playgroud) 背景
我们的企业用户拥有Google Apps帐户.我们希望允许他们(并且只有他们)使用Google帐户登录外联网.理想情况下,我们还希望通过Google域管理用户界面管理权限.一种想法是创建组并将组成员资格与外部网权限相关联.
研究
Google Apps支持使用OAuth 2.0进行登录,并且还支持通过API进行配置,这样我们就可以测试用户是否是群组成员.Provisioning API可能需要管理员凭据.
题
是否可以以编程方式确定Google Apps用户是否是某个组的成员而不需要域管理员凭据?
有没有更好的方法来实现这一目标?
我正在尝试对已安装的应用程序使用新的增量授权,以便在保留现有范围的同时将范围添加到现有授权中.这是使用新include_granted_scopes=true参数完成的.但是,无论我尝试过什么,重新授权总是会完全覆盖范围.这是我编写的一个最小的Bash PoC脚本来演示我的问题:
client_id='716905662885.apps.googleusercontent.com' # throw away client_id (non-prod)
client_secret='CMVqIy_iQqBEMlzjYffdYM8A' # not really a secret
redirect_uri='urn:ietf:wg:oauth:2.0:oob'
while :
do
echo "Please enter a list of scopes (space separated) or CTRL+C to quit:"
read scope
# Form the request URL
# http://goo.gl/U0uKEb
auth_url="https://accounts.google.com/o/oauth2/auth?scope=$scope&redirect_uri=$redirect_uri&response_type=code&client_id=$client_id&approval_prompt=force&include_granted_scopes=true"
echo "Please go to:"
echo
echo "$auth_url"
echo
echo "after accepting, enter the code you are given:"
read auth_code
# swap authorization code for access token
# http://goo.gl/Mu9E5J
auth_result=$(curl -s https://accounts.google.com/o/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" …Run Code Online (Sandbox Code Playgroud) 我正在做一些研究使用谷歌云端硬盘文档的应用程序,但我正在与匿名访问,并在文件中的用户显示名称的问题.
理想情况下,我想以编程方式创建Google云端硬盘文档并设置该文档的共享权限,以允许任何拥有链接的人访问,而无需使用Google云端硬盘帐户登录.
不幸的是,当用户点击链接时,他们会被分配一个显示名称,如"Anonymous Coyote".有没有办法可以在URL中指定显示名称?
为了更清楚,当Google的文档中包含" https://docs.google.com/a/famewebdevelopment.com/document/d/1LGXiFd5x0mHeo38ptqLm0U3jTWYE8qa0h0_w0eFsx8g/edit " 这样的网址时,我希望能够打开该文档通过加载" https://docs.google.com/a/famewebdevelopment.com/document/d/1LGXiFd5x0mHeo38ptqLm0U3jTWYE8qa0h0_w0eFsx8g/edit?user_label=A_user_display_label " 等网址.
要求用户使用Google帐户登录意味着他必须进行两次身份验证 - 一次使用我正在处理的应用程序的用户ID /密码,第二次使用Google凭据.
如果有人能帮我解决这个问题,我将不胜感激!
google-docs google-docs-api google-drive-api google-drive-realtime-api
我想创建一个应用程序,可以将文件添加到谷歌驱动器并将该文件共享给其他用户(例如abc@gmail.com)。该用户 abc@gmail.com 应该登录到应用程序,然后他可以查看并下载其驱动器中的所有可用文件。目前我已经使用谷歌驱动器的服务帐户来实现此目的。我可以将文件上传到谷歌驱动器,并且可以将其共享给用户 abc@gmail.com。但我面临以下问题。
使用电子邮件 xyz@gmail.com 我注册了驱动器并创建了一个项目,但是当我创建文件并使用驱动器 API 将其共享给用户 abc@gmail.com 时,该文件未在 xyz@gmail.com 的驱动器上列出,但是当我尝试通过 API 访问该文件,我可以看到这些文件。
对于用户 abc@gmail.com,共享文件在他的驱动器中可用,我可以看到,当我通过网络访问他的驱动器时,但当我尝试通过 API 访问它时,它显示没有文件。
请建议我哪里出错了。我可以这样做吗?
for user **xyz@gmail.com
$CLIENT_ID='xxxxxxxxx.apps.googleusercontent.com';
$SERVICE_ACCOUNT_EMAIL = 'xxxxxxxxxxxx@developer.gserviceaccount.com';
$SERVICE_ACCOUNT_PKCS12_FILE_PATH = 'xxxxxxxxxx-privatekey.p12';**
For user **abc@gmail.com
$CLIENT_ID='yyyyyyyyyyy.apps.googleusercontent.com';
$SERVICE_ACCOUNT_EMAIL = 'yyyyyyyyyyyy@developer.gserviceaccount.com';
$SERVICE_ACCOUNT_PKCS12_FILE_PATH = 'yyyyyyyyyyyy-privatekey.p12';**
Run Code Online (Sandbox Code Playgroud)
使用用户 xyz@gmail ID 创建了一个项目,并使用他上面的 clientID、帐户电子邮件、密钥文件创建了文件:
function insertFile($service, $title, $description, $parentId, $mimeType, $filename) {
$file = new Google_DriveFile();
$file->setTitle($title);
$file->setDescription($description);
$file->setMimeType($mimeType);
// Set the parent folder.
if ($parentId != null) {
$parent = new ParentReference();
$parent->setId($parentId);
$file->setParents(array($parent));
}
try {
$data …Run Code Online (Sandbox Code Playgroud)