【发布时间】:2019-08-18 15:06:00
【问题描述】:
我正在尝试使用此PHP 代码获得电子邮件的角色(是否为超级管理员):
$email = 'an email with the same domain';
$credentials_file = '../service-account.json';
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$credentials_file);
// Initialize Google Client
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
// scopes to change signature
$client->setScopes(['https://www.googleapis.com/auth/gmail.settings.basic',
'https://www.googleapis.com/auth/gmail.settings.sharing',
'https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/userinfo.profile']);
// Initialize Gmail
$gmail = new Google_Service_Gmail($client);
// set signature
$signature = new Google_Service_Gmail_SendAs();
// update signature
我正在使用最新的PHP SDK。该电子邮件始终与超级管理员电子邮件具有相同的域,但他/她并不总是超级管理员。
我试过的是:
var_dump($gmail->users->getProfile($email));
,但我收到一个错误:
失败的前提条件, 消息:错误请求”
我从这里读到 - Google Docs,我需要列出的权限之一,并且我拥有 https://www.googleapis.com/auth/gmail.readonly,我已将其添加到超级管理员用户的 Google 管理控制台中。
如何获取同域用户邮箱的角色?
【问题讨论】:
标签: php gmail-api google-workspace