Get details about a membership

  • This guide explains how to use the get() method to retrieve details about a membership in a Google Chat space.

  • Google Workspace administrators can use the get() method with administrator privileges to retrieve membership details for any user in their organization.

  • To get membership details, you need to authenticate using either app authentication or user authentication with the appropriate authorization scopes.

  • You need to provide the name of the membership, which includes the space ID and member ID, to the get() method.

  • The get() method returns a Membership object containing details about the specified membership.

This guide explains how to use the get() method on the Membership resource of the Google Chat API to get details about a membership in a space.

If you're a Google Workspace administrator, you can call the get() method to retrieve details about any membership in your Google Workspace organization.

The Membership resource represents whether a human user or Google Chat app is invited to, part of, or absent from a space.

Authenticating with app authentication lets a Chat app get memberships from spaces that it has access to in Google Chat (for example, spaces it's a member of), but excludes Chat app memberships, including its own. Authenticating with user authentication returns memberships from spaces that the authenticated user has access to.

Prerequisites

Node.js

Python

Java

Apps Script

To get details about a membership in Google Chat, pass the following in your request:

  • With app authentication, specify the chat.bot authorization scope. With user authentication, specify the chat.memberships.readonly or chat.memberships authorization scope. As a best practice, choose the most restrictive scope that still allows your app to function.
  • Call the GetMembership() method.
  • Pass the name of the membership to get. Obtain the membership name from the membership resource of Google Chat.

Get a membership with user authentication

Here's how to get a membership with user authentication:

Node.js

Python

Java

Apps Script

To run this sample, replace the following:

  • SPACE_NAME: the ID from the space's name. You can obtain the ID by calling the ListSpaces() method or from the space's URL.
  • MEMBER_NAME: the ID from the member's name. You can obtain the ID by calling the ListMemberships() method.

The Chat API returns an instance of Membership detailing the specified membership.

Get a membership with app authentication

Here's how to get a membership with app authentication:

Node.js

Python

Java

Apps Script

To run this sample, replace the following:

  • SPACE_NAME: the ID from the space's name. You can obtain the ID by calling the ListSpaces() method or from the space's URL.
  • MEMBER_NAME: the ID from the member's name. You can obtain the ID by calling the ListMemberships() method.

The Chat API returns an instance of Membership detailing the specified membership.

Get details about memberships as a Google Workspace administrator

If you're a Google Workspace administrator, you can call the GetMembership() method to retrieve details about a membership for any user in your Google Workspace organization.

To call this method as a Google Workspace administrator, do the following:

For more information and examples, see Manage Google Chat spaces as a Google Workspace administrator.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.