Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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:我可以使用帐户和密码来授权GoogleAPI客户端连接吗?_Php_Google Api Php Client - Fatal编程技术网

PHP:我可以使用帐户和密码来授权GoogleAPI客户端连接吗?

PHP:我可以使用帐户和密码来授权GoogleAPI客户端连接吗?,php,google-api-php-client,Php,Google Api Php Client,在Google Docs api指南中,Oauth2是作为授权方法提供的。以下是授权代码: $client = new Google_Client(); // Get your credentials from the console $client->setClientId('...'); $client->setClientSecret('...'); $client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob'); $client

在Google Docs api指南中,Oauth2是作为授权方法提供的。以下是授权代码:

$client = new Google_Client();
// Get your credentials from the console
$client->setClientId('...');
$client->setClientSecret('...');
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));

$service = new Google_DriveService($client);

$authUrl = $client->createAuthUrl();

// Request authorization
print "Please visit:\n$authUrl\n\n";
print "Please enter the auth code:\n";
$authCode = trim(fgets(STDIN));

// Exchange authorization code for access token
$accessToken = $client->authenticate($authCode);
$client->setAccessToken($accessToken);
但是,这种授权要求您单击链接并手动授权。我想要的是使用电子邮件帐户和密码来授权连接,这是可能的吗

顺便说一句,我不想使用Zend Gdata。提前感谢。

您可以使用

对于这些类型的服务器到服务器交互,您需要一个服务 帐户,它是属于您的应用程序的帐户 对单个最终用户的。您的应用程序在上调用Google API 代表服务帐户,不需要用户同意。(在 在非服务帐户场景中,您的应用程序在 代表最终用户,有时需要用户同意。)


使用PHP库。

谢谢,这就是我要找的!