다음을 통해 공유


ChainedTokenCredential class

getToken 메서드 중 하나가 액세스 토큰을 반환할 때까지 여러 TokenCredential 구현을 순서대로 시도할 수 있도록 합니다. 자세한 내용은 ChainedTokenCredential 개요참조하세요.

생성자

ChainedTokenCredential(TokenCredential[])

지정된 자격 증명을 사용하여 ChainedTokenCredential 인스턴스를 만듭니다.

메서드

getToken(string | string[], GetTokenOptions)

연결된 TokenCredential 구현 중 하나에서 반환된 첫 번째 액세스 토큰을 반환합니다. 하나 이상의 자격 증명이 AuthenticationError throw하고 자격 증명이 액세스 토큰을 반환하지 않은 경우 AggregateAuthenticationError throw합니다.

이 메서드는 Azure SDK 클라이언트 라이브러리에서 자동으로 호출됩니다. 이 메서드를 직접 호출할 수 있지만 토큰 캐싱 및 토큰 새로 고침도 처리해야 합니다.

생성자 세부 정보

ChainedTokenCredential(TokenCredential[])

지정된 자격 증명을 사용하여 ChainedTokenCredential 인스턴스를 만듭니다.

new ChainedTokenCredential(sources: TokenCredential[])

매개 변수

sources

TokenCredential[]

순서대로 시도할 구현을 TokenCredential.

사용 예:

import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";

const tenantId = "<tenant-id>";
const clientId = "<client-id>";
const clientSecret = "<client-secret>";
const anotherClientId = "<another-client-id>";
const anotherSecret = "<another-client-secret>";

const firstCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const secondCredential = new ClientSecretCredential(tenantId, anotherClientId, anotherSecret);

const credentialChain = new ChainedTokenCredential(firstCredential, secondCredential);

메서드 세부 정보

getToken(string | string[], GetTokenOptions)

연결된 TokenCredential 구현 중 하나에서 반환된 첫 번째 액세스 토큰을 반환합니다. 하나 이상의 자격 증명이 AuthenticationError throw하고 자격 증명이 액세스 토큰을 반환하지 않은 경우 AggregateAuthenticationError throw합니다.

이 메서드는 Azure SDK 클라이언트 라이브러리에서 자동으로 호출됩니다. 이 메서드를 직접 호출할 수 있지만 토큰 캐싱 및 토큰 새로 고침도 처리해야 합니다.

function getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>

매개 변수

scopes

string | string[]

토큰에 액세스할 수 있는 범위 목록입니다.

options
GetTokenOptions

TokenCredential 구현에서 수행할 수 있는 요청을 구성하는 데 사용되는 옵션입니다.

반환

Promise<AccessToken>