Google Group Members Retrieve
Retrieves Google Group members (email address) list. By checking group members (ML members) on a regular basis, ML management becomes easier. It also helps to prevent e-mail transmission to unnecessary members or leaving out intended recipients from information sharing.
2017 © Questetra, Inc. (MIT License)
Configs
  • A: Set OAuth2 Config Name (at [OAuth 2.0 Setting]) *#{EL}
  • B: Select STRING for Group Address (Non-existent Error) *
  • C: Select STRING DATA for Email list of members (update) *
  • X: Select STRING DATA for Access Log (update)
Script
//// == 工程コンフィグの参照 / Config Retrieving ==
var oauth2  = configs.get( "conf_OAuth2" ) + "";
var dataIdB = configs.get( "conf_DataIdB" ); // (returns key)
var dataIdC = configs.get( "conf_DataIdC" ); // (returns key)
var dataIdX = configs.get( "conf_DataIdX" ); // (returns key)

//// == ワークフローデータの参照 / Data Retrieving ==
var targetGroup = data.get( dataIdB ) + "";

//// == 演算 / Calculating ==
var membersEmail = "";
var accessLog = "";
var token = httpClient.getOAuth2Token( oauth2 );

var uri = "https://www.googleapis.com/admin/directory/v1/groups/" + targetGroup + "/members/";
var response = httpClient.begin()
  .bearer( token )
  .get( uri );
var groupMembersObj = JSON.parse( response.getResponseAsString() );
for( var i = 0; i < groupMembersObj.members.length; i++ ){
  membersEmail += groupMembersObj.members[i].email + "\n";
}
accessLog += "---GET request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "\n";

//// == ワークフローデータへの代入 / Data Updating ==
retVal.put( dataIdC, membersEmail );
if( dataIdX !== "" ){
  retVal.put( dataIdX, accessLog );
}

Download

Capture

Notes

  • You need to Enable [Admin SDK Directory API] at Google Developers Console beforehand and obtain “Client ID” and “Client secret”
  • On G Suite domain administration screen, authorize “Client ID” and its communication scope

See also

%d bloggers like this: