Share via


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>