Get a user's space notification settings

This guide explains how to use the get() method on the SpaceNotificationSetting resource of the Google Chat API to get a user's space notification settings.

The SpaceNotificationSetting resource is a singleton resource that represents details about a specified user's space notification settings.

Prerequisites

Node.js

Get the calling user's space notification settings

To get details about a user's space notification settings, include the following in your request:

  • Specify the chat.users.spacesettings authorization scope.
  • Call the GetSpaceNotificationSetting() method, passing the name of the space notification settings to get which includes a user ID or alias and a space ID. You can only get notification settings for the calling user. To specify the settings, use one of the following:
    • The me alias. For example, users/me/spaces/ SPACE_ID /spaceNotificationSetting .
    • The calling user's Google Workspace email address. For example, users/user@example.com/spaces/ SPACE_ID /spaceNotificationSetting .
    • The calling user's user ID. For example, users/ USER /spaces/ SPACE /spaceNotificationSetting .

The following example gets the calling user's space notification settings:

Node.js

chat/client-libraries/cloud/get-space-notification-setting-user-cred.js
 import 
  
 { 
 createClientWithUserCredentials 
 } 
  
 from 
  
 './authentication-utils.js' 
 ; 
 const 
  
 USER_AUTH_OAUTH_SCOPES 
  
 = 
  
 [ 
 'https://www.googleapis.com/auth/chat.users.spacesettings' 
 ]; 
 // This sample shows how to get the space notification setting for the calling user 
 async 
  
 function 
  
 main 
 () 
  
 { 
  
 // Create a client 
  
 const 
  
 chatClient 
  
 = 
  
 await 
  
 createClientWithUserCredentials 
 ( 
 USER_AUTH_OAUTH_SCOPES 
 ); 
  
 // Initialize request argument(s), replace the SPACE_NAME with an actual space name. 
  
 const 
  
 request 
  
 = 
  
 { 
  
 name 
  
 : 
  
 'users/me/spaces/SPACE_NAME/spaceNotificationSetting' 
  
 }; 
  
 // Make the request 
  
 const 
  
 response 
  
 = 
  
 await 
  
 chatClient 
 . 
 getSpaceNotificationSetting 
 ( 
 request 
 ); 
  
 // Handle the response 
  
 console 
 . 
 log 
 ( 
 response 
 ); 
 } 
 main 
 (). 
 catch 
 ( 
 console 
 . 
 error 
 ); 

To run this sample, replace SPACE_ID with the ID from the space's name . You can obtain the ID by calling the ListSpaces() method or from the space's URL.

The Google Chat API gets the specified space notification settings and returns an instance of SpaceNotificationSetting .

Create a Mobile Website
View Site in Mobile | Classic
Share by: