【发布时间】:2014-04-09 21:38:13
【问题描述】:
在 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。提前致谢。
【问题讨论】: