사용자 초대 API 설정

이 페이지에서는 Cloud ID 사용자 초대 API를 설정하는 방법을 설명합니다.

API 사용 설정 및 사용자 인증 정보 설정

  1. Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Cloud Identity API 사용 설정

    API 사용 설정

  4. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  5. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  7. Cloud Identity API 사용 설정

    API 사용 설정

  8. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  9. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.

Python 클라이언트 라이브러리 설치

Python 클라이언트 라이브러리를 설치하려면 다음 명령어를 실행합니다.

  pip install --upgrade google-api-python-client google-auth \
    google-auth-oauthlib google-auth-httplib2

Python 개발 환경 설정에 관한 자세한 내용은 Python 개발 환경 설정 가이드를 참조하세요.

도메인 전체 위임을 사용하여 서비스 계정으로 인증

관리자를 대신하여 사용자 초대를 관리할 수 있도록 도메인 전체 권한이 있는 계정을 제공하려면, 서비스 계정으로 인증한 다음 도메인 전체 권한을 부여해야 합니다.

자세한 내용은 서비스 계정에 도메인 전체 권한 위임을 참조하세요. 서비스 계정을 승인하려면 다음 범위를 제공해야 합니다.

  • https://www.googleapis.com/auth/cloud-identity.userinvitations

클라이언트 인스턴스화

다음 예시에서는 서비스 계정 사용자 인증 정보를 사용하여 클라이언트를 인스턴스화하는 방법을 보여줍니다. 대신 최종 사용자로 인증하려면 서비스 계정의 사용자 인증 정보 객체를 웹 서버 애플리케이션용 OAuth 2.0 사용에서 앞서 얻은 사용자 인증 정보로 바꿉니다.

Python

from google.oauth2 import service_account
import googleapiclient.discovery

SCOPES = ['https://www.googleapis.com/auth/cloud-identity.userinvitations']
SERVICE_ACCOUNT_FILE = '/path/to/service-account-file.json'

def create_service():
  credentials = service_account.Credentials.from_service_account_file(
    SERVICE_ACCOUNT_FILE, scopes=SCOPES)
  delegated_credentials = credentials.with_subject('user@altostrat.com')

  service_name = 'cloudidentity'
  api_version = 'v1'
  service = googleapiclient.discovery.build(
    service_name,
    api_version,
    credentials=delegated_credentials)

  return service

이제 사용자 초대 API를 호출할 수 있습니다.