AuthorizationCodeCredential class

Microsoft Entra IDのドキュメントで詳細に説明されている認可コードフローを通じて取得した認証コードを使用して、Microsoft Entra IDへの認証を可能にします。

https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow

コンストラクター

AuthorizationCodeCredential(string, string, string, string, AuthorizationCodeCredentialOptions)

Microsoft Entra IDから取得した認証を使ってアクセストークンを要求するために必要な詳細を含むAuthorizationCodeCredentialのインスタンスを作成します。

現在、この資格情報のユーザーが承認コード フローを開始して、この資格情報で使用する承認コードを取得する必要があります。 このフローの完全な例を次に示します。

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts

AuthorizationCodeCredential(string, string, string, string, string, AuthorizationCodeCredentialOptions)

Microsoft Entra IDから取得した認証を使ってアクセストークンを要求するために必要な詳細を含むAuthorizationCodeCredentialのインスタンスを作成します。

現在、この資格情報のユーザーが承認コード フローを開始して、この資格情報で使用する承認コードを取得する必要があります。 このフローの完全な例を次に示します。

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts

メソッド

getToken(string | string[], GetTokenOptions)

Microsoft Entra IDで認証し、成功するとアクセストークンを返します。 認証に失敗すると、CredentialUnavailableError がスローされ、エラーの詳細が表示されます。

コンストラクターの詳細

AuthorizationCodeCredential(string, string, string, string, AuthorizationCodeCredentialOptions)

Microsoft Entra IDから取得した認証を使ってアクセストークンを要求するために必要な詳細を含むAuthorizationCodeCredentialのインスタンスを作成します。

現在、この資格情報のユーザーが承認コード フローを開始して、この資格情報で使用する承認コードを取得する必要があります。 このフローの完全な例を次に示します。

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts

new AuthorizationCodeCredential(tenantId: string, clientId: string, authorizationCode: string, redirectUri: string, options?: AuthorizationCodeCredentialOptions)

パラメーター

tenantId

string

Microsoft Entraのテナント(ディレクトリ)IDまたは名前。 マルチテナント シナリオを処理する場合は、"common" を使用できます。

clientId

string

テナント内のアプリ登録のクライアント (アプリケーション) ID。

authorizationCode

string

承認コード フローの後から受信した承認コード。 この承認コードは、アクセス トークンを取得するためにまだ使用されていない必要があります。

redirectUri

string

承認コードの要求に使用されたリダイレクト URI。 アプリ登録用に構成されているのと同じ URI である必要があります。

options
AuthorizationCodeCredentialOptions

アクセス トークン要求を行うクライアントを構成するためのオプション。

AuthorizationCodeCredential(string, string, string, string, string, AuthorizationCodeCredentialOptions)

Microsoft Entra IDから取得した認証を使ってアクセストークンを要求するために必要な詳細を含むAuthorizationCodeCredentialのインスタンスを作成します。

現在、この資格情報のユーザーが承認コード フローを開始して、この資格情報で使用する承認コードを取得する必要があります。 このフローの完全な例を次に示します。

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts

new AuthorizationCodeCredential(tenantId: string, clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: AuthorizationCodeCredentialOptions)

パラメーター

tenantId

string

Microsoft Entraのテナント(ディレクトリ)IDまたは名前。 マルチテナント シナリオを処理する場合は、"common" を使用できます。

clientId

string

テナント内のアプリ登録のクライアント (アプリケーション) ID。

clientSecret

string

アプリ登録用に生成されたクライアント シークレット

authorizationCode

string

承認コード フローの後から受信した承認コード。 この承認コードは、アクセス トークンを取得するためにまだ使用されていない必要があります。

redirectUri

string

承認コードの要求に使用されたリダイレクト URI。 アプリ登録用に構成されているのと同じ URI である必要があります。

options
AuthorizationCodeCredentialOptions

アクセス トークン要求を行うクライアントを構成するためのオプション。

メソッドの詳細

getToken(string | string[], GetTokenOptions)

Microsoft Entra IDで認証し、成功するとアクセストークンを返します。 認証に失敗すると、CredentialUnavailableError がスローされ、エラーの詳細が表示されます。

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

パラメーター

scopes

string | string[]

トークンがアクセスできるスコープの一覧。

options
GetTokenOptions

この TokenCredential 実装が行う可能性がある要求を構成するために使用されるオプション。

返品

Promise<AccessToken>