共用方式為


ClientSecretCredential class

使用針對應用程式註冊產生的用戶端密碼,啟用驗證以Microsoft Entra標識符。 如需如何設定用戶端密碼的詳細資訊,請參閱這裡:

https://learn.microsoft.com/entra/identity-platform/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application

建構函式

ClientSecretCredential(string, string, string, ClientSecretCredentialOptions)

建立 ClientSecretCredential 的實例,其中包含使用用戶端密碼針對 Microsoft Entra ID 進行驗證所需的詳細數據。

方法

getToken(string | string[], GetTokenOptions)

使用 Microsoft Entra 識別碼進行驗證,並在成功時傳回存取令牌。 如果驗證失敗,CredentialUnavailableError 將會擲回失敗的詳細數據。

建構函式詳細資料

ClientSecretCredential(string, string, string, ClientSecretCredentialOptions)

建立 ClientSecretCredential 的實例,其中包含使用用戶端密碼針對 Microsoft Entra ID 進行驗證所需的詳細數據。

new ClientSecretCredential(tenantId: string, clientId: string, clientSecret: string, options?: ClientSecretCredentialOptions)

參數

tenantId

string

Microsoft Entra 租使用者 (目錄) 識別符。

clientId

string

租用戶中應用程式註冊的用戶端(應用程式)標識碼。

clientSecret

string

針對應用程式註冊所產生的客戶端密碼。

options
ClientSecretCredentialOptions

設定發出驗證要求的客戶端的選項。

方法詳細資料

getToken(string | string[], GetTokenOptions)

使用 Microsoft Entra 識別碼進行驗證,並在成功時傳回存取令牌。 如果驗證失敗,CredentialUnavailableError 將會擲回失敗的詳細數據。

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

參數

scopes

string | string[]

令牌將具有存取權的範圍清單。

options
GetTokenOptions

用來設定此 TokenCredential 實作可能提出的任何要求的選項。

傳回

Promise<AccessToken>