我无法将用户添加到Google群组。我能够生成令牌并将其用于我的日历API -
使用403错误代码抛出错误的原因,错误在下面给出
"{ "error":
{ "errors":
[ { "domain": "global", "reason": "insufficientPermissions", "message": "Insufficient Permission" } ],
"code": 403, "message": "Insufficient Permission"
}
}"
我正在使用帐户svc.gcalendar@timesinternet.in
执行上述操作,并且我想添加用户名devendra.kumarsingh@timesinternet.in
我的代码是
$groupKey='TIL-Gurgaon@timesinternet.in'; //TIL-Noida@timesinternet.in
$role='MEMBER';
$userEmail='devendra.kumarsingh@timesinternet.in';
$curlPost=array();
$curlPost = array("email"=>$userEmail,"role"=>$role);
$url_events = 'https://www.googleapis.com/admin/directory/v1/groups/'.$groupKey.'/members';
$condtion['user_email']='svc.gcalendar@timesinternet.in';
//Getting Token
$datalist=$this->Common->getSingleInfoFromTable('oauth_session',$condtion,'id');
$access_token=$datalist['access_token'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_events);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
//xcurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '. $access_token, 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($curlPost));
$data = json_decode(curl_exec($ch), true);
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
答案 0 :(得分:0)
这个"由api"添加功能仅适用于具有gsuite订阅的组织。您是否可以确认您拥有GSuite并且已在启用了GSuite并且还有权添加到该组的帐户下登录?
https://developers.google.com/admin-sdk/directory/v1/guides/manage-group-members