0

I made a Web App using angular 2 and created a Sign In and Sign Out with Google API. I'm reading this documentation:

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

But I'm don't understand how to use it.

How can I use the Google Groups API to add new members to group?

Victor Mendes
  • 179
  • 20

1 Answers1

0

You use the http Service to make http requests

There's more info here: https://angular.io/docs/ts/latest/guide/server-communication.html

I didn't read Google's full documentation but the function below should get you started.

addNewUserToGroup(email: string, role:string, groupKey: string): Observable<Hero> {
 let headers = new Headers({ 'Content-Type': 'application/json' });
 let options = new RequestOptions({ headers: headers });
 let data = { 
   email: email,
   role: role
 } 
 return this.http.post("https://www.googleapis.com/admin/directory/v1/groups/"+ groupKey +"/members", { data }, options)
                .map(response => response.json());
}

Good luck

bakerhumadi
  • 341
  • 1
  • 4