멤버십 세부정보 보기

이 가이드에서는 membership 리소스에서 get 메서드를 사용하는 방법을 설명합니다. 스페이스의 멤버십에 관한 세부정보를 가져올 수 있습니다.

Membership 리소스 사람 또는 Google Chat 앱이 초대되었는지 여부를 나타냅니다. 빈 공간을 사용할 수 있습니다.

다음을 사용하여 인증 앱 인증 채팅 앱이 기존 스페이스의 멤버십을 받을 수 있도록 허용 Google Chat의 에 대한 액세스 권한 (예: 참여자인 스페이스)이지만 자체 멤버십을 포함한 채팅 앱 멤버십 인증 중 다음 코드로 교체합니다. 사용자 인증 인증된 사용자가 액세스할 수 있는 스페이스에서 멤버십을 반환합니다.

기본 요건

Python

  • Python 3.6 이상
  • pip 패키지 관리 도구
  • 최신 Google 클라이언트 라이브러리 이러한 앱을 설치하거나 업데이트하려면 다음 단계를 따르세요. 명령줄 인터페이스에서 다음 명령어를 실행합니다.
    pip3 install --upgrade google-api-python-client google-auth-oauthlib
    

멤버십 세부정보 보기

Google Chat의 멤버십에 관해 자세히 알아보려면 요청:

  • 다음으로 바꿉니다. 앱 인증의 경우 chat.bot 승인 범위 다음으로 바꿉니다. 사용자 인증 chat.memberships.readonly 또는 chat.memberships 승인을 지정합니다. 범위를 제공합니다 가장 제한적인 범위를 선택하는 것이 좋습니다. 앱이 작동할 수 있습니다
  • 먼저 get 메서드membership 리소스.
  • 멤버십의 name를 전달하면 됩니다. 멤버십 리소스입니다.

멤버십에 가입하는 방법 사용자 인증:

Python

  1. 작업 디렉터리에 chat_membership_get.py라는 파일을 만듭니다.
  2. chat_membership_get.py에 다음 코드를 포함합니다.

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient.discovery import build
    
    # Define your app's authorization scopes.
    # When modifying these scopes, delete the file token.json, if it exists.
    SCOPES = ["https://www.googleapis.com/auth/chat.memberships.readonly"]
    
    def main():
        '''
        Authenticates with Chat API via user credentials,
        then gets details about a specified membership.
        '''
    
        # Authenticate with Google Workspace
        # and get user authorization.
        flow = InstalledAppFlow.from_client_secrets_file(
                    'client_secrets.json', SCOPES)
        creds = flow.run_local_server()
    
        # Build a service endpoint for Chat API.
        chat = build('chat', 'v1', credentials=creds)
    
        # Use the service endpoint to call Chat API.
        result = chat.spaces().members().get(
    
            # The membership to get.
            #
            # Replace SPACE with a space name.
            # Obtain the space name from the spaces resource of Chat API,
            # or from a space's URL.
            #
            # Replace MEMBER with a membership name.
            # Obtain the membership name from the memberships resource of
            # Chat API.
            name='spaces/SPACE/members/MEMBER'
    
        ).execute()
    
        # Prints details about the membership.
        print(result)
    
    if __name__ == '__main__':
        main()
    
  3. 코드에서 다음을 바꿉니다.

    • SPACE: 스페이스 이름으로, 다음에서 가져올 수 있습니다. spaces.list 메서드 Chat API 또는 스페이스의 URL에서 가져올 수 있습니다.
    • MEMBER: 가져올 수 있는 멤버십 이름입니다. - spaces.members.list 메서드 채팅 API에서 지원됩니다.
  4. 작업 디렉터리에서 샘플을 빌드하고 실행합니다.

    python3 chat_membership_get.py
    

Chat API는 membership 회원자격을 확인할 수 있습니다.