问题:
企业版Google云端硬盘尚无法将团队驱动器打开到整个Internet。
我不想将文件夹移动到个人磁盘上-与团队驱动器上的团队合作很方便。
我要如何解决该问题:
完成的操作:
use Google_Client;
use Google_Service_Directory;
use Google_Service_Directory_Member;
class GoogleClient
{
/**
* Returns an authorized API client.
* @return Google_Client the authorized client object
*/
private function getClient()
{
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setApplicationName("LeadStartup");
$client->setScopes([
Google_Service_Directory::ADMIN_DIRECTORY_GROUP,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP_MEMBER,
Google_Service_Directory::ADMIN_DIRECTORY_USER
]);
$client->setSubject('a.kolomensky@leadstartup.ru');
return $client;
}
public function addEmailToPublicGroup()
{
$member = new Google_Service_Directory_Member();
$member->setEmail('m.ryazhenka@leadstartup.ru');
$member->setRole('MEMBER');
$directory = new Google_Service_Directory($this->getClient());
$directory->members->insert('friends@leadstartup.ru', $member);
}
}
启用了域范围委派。
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . __DIR__ . '/private/LeadStartup-8c8edffdb357.json');
结果是,我收到401错误 unauthorized_client Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.
请帮我解决这个问题。我想念的是什么?