List sections

This guide explains how to use the list method on the Section resource of the Google Chat API to list sections available to the authenticated user in Google Chat.

For more information, see Create and organize sections in Google Chat .

Prerequisites

Python

List sections

To list sections with user authentication , pass the following in your request:

  • Specify the chat.users.sections or chat.users.sections.readonly authorization scope.
  • Call the ListSections method.
  • Set parent to users/me .

The following example lists sections:

Python

  from 
  
 google.cloud 
  
 import 
 chat_v1 
 def 
  
 list_sections 
 (): 
 # Create a client 
 client 
 = 
 chat_v1 
 . 
 ChatServiceClient 
 () 
 # Initialize request 
 request 
 = 
 chat_v1 
 . 
 ListSectionsRequest 
 ( 
 parent 
 = 
 "users/me" 
 ) 
 # Make the request 
 page_result 
 = 
 client 
 . 
 list_sections 
 ( 
 request 
 = 
 request 
 ) 
 # Handle the response 
 for 
 section 
 in 
 page_result 
 : 
 print 
 ( 
 section 
 ) 
 

The Chat API returns a list of Section resources.

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