From 7a8eca76eed9a4a1b62fb3e4b0759e394f1f45b5 Mon Sep 17 00:00:00 2001 From: Pierrick Voulet <6769971+PierrickVoulet@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:45:43 -0400 Subject: [PATCH] feat: add create membership for group code sample (#488) Co-authored-by: pierrick --- chat/advanced-service/Main.gs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/chat/advanced-service/Main.gs b/chat/advanced-service/Main.gs index 01ad85d41..f9f7876d0 100644 --- a/chat/advanced-service/Main.gs +++ b/chat/advanced-service/Main.gs @@ -79,6 +79,33 @@ function createMembershipUserCredForApp() { } // [END chat_create_membership_user_cred_for_app] +// [START chat_create_membership_user_cred_for_group] +/** + * This sample shows how to create membership with user credential for a group + * + * It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.memberships' + * referenced in the manifest file (appsscript.json). + */ +function createMembershipUserCredForGroup() { + // Initialize request argument(s) + // TODO(developer): Replace SPACE_NAME here. + const parent = 'spaces/SPACE_NAME'; + const membership = { + groupMember: { + // TODO(developer): Replace GROUP_NAME here + name: 'groups/GROUP_NAME' + } + }; + + // Make the request + const response = Chat.Spaces.Members.create(membership, parent); + + // Handle the response + console.log(response); +} +// [END chat_create_membership_user_cred_for_group] + + // [START chat_create_message_app_cred] /** * This sample shows how to create message with app credential