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
- A Business or Enterprise Google Workspace account with access to Google Chat.
- Set up your environment:
- Create a Google Cloud project.
- Configure the OAuth consent screen.
- Enable and configure the Google Chat API with a name, icon, and description for your Chat app.
- Install the Node.js Cloud Client Library.
-
Create OAuth client ID credentials for a desktop application. To run the sample in this
guide, save the credentials as a JSON file named
client_secrets.json
to your local directory.
- Choose an authorization scope that supports user authentication.
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 thename
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
The following example gets the calling user's space notification settings:
Node.js
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
.