0

我无法将用户添加到 Google 群组。我能够生成令牌并将其用于我的日历 API-

  1. 为 G Calendar API 生成的访问令牌是否可用于将用户添加到 Google Group PLS 的过程?
  2. 如果上述步骤为否,那么如何为 Google 群组生成令牌?
  3. 使用 403 错误代码引发错误的原因,错误如下

    "{ "error": 
        { "errors": 
            [ { "domain": "global", "reason": "insufficientPermissions", "message": "Insufficient Permission" } ], 
           "code": 403, "message": "Insufficient Permission" 
        } 
    }"
    
  4. 我正在使用一个帐户svc.gcalendar@timesinternet.in进行上述操作,我想添加一个用户名devendra.kumarsingh@timesinternet.in

  5. 在 API Explorer 中复制成功,但无法使用我的 api 生成令牌。
  6. 我的代码是

    $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);
    
4

1 回答 1

0

此“通过 api 添加”功能仅适用于订阅了 gsuite 的组织。您能否确认您拥有 GSuite 并使用启用了 GSuite 且有权添加到组的帐户登录?

https://developers.google.com/admin-sdk/directory/v1/guides/manage-group-members

于 2018-05-16T05:11:49.207 回答