맞춤 사용자 인증 정보로 클라이언트 만들기

이 스니펫은 고정 사용자 인증 정보 제공자를 사용하여 관리 클라이언트를 만드는 방법을 보여줍니다. 기본 애플리케이션 사용자 인증 정보에 의존하는 대신 사용자 인증 정보를 명시적으로 제공해야 하는 경우 이 메서드를 사용합니다.

코드 샘플

Java

AlloyDB에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.cloud.alloydb.v1.AlloyDBAdminClient;
import com.google.cloud.alloydb.v1.AlloyDBAdminSettings;
import com.google.cloud.alloydb.v1.myCredentials;

public class SyncCreateSetCredentialsProvider {

  public static void main(String[] args) throws Exception {
    syncCreateSetCredentialsProvider();
  }

  public static void syncCreateSetCredentialsProvider() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    AlloyDBAdminSettings alloyDBAdminSettings =
        AlloyDBAdminSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
            .build();
    AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.create(alloyDBAdminSettings);
  }
}

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저 참조하기