共用方式為


DeviceCodeCredentialOptions interface

定義 Node.js 的 InteractiveBrowserCredential 類別選項。

Extends

屬性

clientId

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

tenantId

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

userPromptCallback

將叫用以向用戶顯示 DeviceCodeInfo 的回呼函式。 如果未指派,我們會在控制台中自動記錄裝置程式代碼資訊和驗證指示。

繼承的屬性

additionallyAllowedTenants

針對多租使用者應用程式,指定認證可能會取得令牌的其他租使用者。 新增通配符值 「*」,以允許認證取得安裝應用程式的任何租使用者令牌。

additionalPolicies

要包含在 HTTP 管線中的其他原則。

allowInsecureConnection

如果要求是透過 HTTP 傳送,而不是 HTTPS,請將 設定為 true

authenticationRecord

先前驗證的結果,可用來擷取每個個別帳戶的快取認證。 如果應用程式想要針對每個用戶端標識碼和租使用者標識碼配對使用一個以上的帳戶,就必須提供此功能。

您可以藉由呼叫認證 authenticate() 的方法來擷取此記錄,如下所示:

const authenticationRecord = await credential.authenticate();
authorityHost

用於驗證要求的授權單位主機。 可能的值可透過 AzureAuthorityHosts 取得。 預設值為 "https://login.microsoftonline.com"。

disableAutomaticAuthentication

如果需要手動驗證,會擲回 getToken。 開發人員必須呼叫 authenticate() 以控制手動驗證的時機。

disableInstanceDiscovery

欄位會決定嘗試驗證時是否執行實例探索。 將此設定為 true 會完全停用實例探索和授權單位驗證。 因此,請務必確保已設定的授權主機有效且值得信任。 這項功能適用於無法連線到元數據端點的情況,例如私人雲端或 Azure Stack。 實例探索的程式需要從 https://login.microsoft.com/ 中擷取授權單位元數據,以驗證授權單位。

httpClient

將用來傳送 HTTP 要求的 HttpClient。

loggingOptions

允許使用者設定記錄原則選項的設定、允許記錄帳戶資訊和客戶支援的個人標識資訊。

proxyOptions

設定傳出要求的 Proxy 選項。

redirectOptions

重新導向回應處理方式的選項。

retryOptions

控制如何重試失敗要求的選項。

telemetryOptions

將一般遙測和追蹤資訊設定為傳出要求的選項。

tlsOptions

設定 TLS 驗證的選項

tokenCachePersistenceOptions

如果儲存認證時) ,則提供給持續性層的選項 (。

您必須先註冊持續性提供者外掛程式。 @azure/identity-cache-persistence請參閱 NPM 上的套件。

範例:

import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";

useIdentityPlugin(cachePersistencePlugin);

async function main() {
  const credential = new DeviceCodeCredential({
    tokenCachePersistenceOptions: {
      enabled: true
    }
  });
}

main().catch((error) => {
  console.error("An error occurred:", error);
  process.exit(1);
});
userAgentOptions

將使用者代理程式詳細數據新增至傳出要求的選項。

屬性詳細資料

clientId

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

clientId?: string

屬性值

string

tenantId

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

tenantId?: string

屬性值

string

userPromptCallback

將叫用以向用戶顯示 DeviceCodeInfo 的回呼函式。 如果未指派,我們會在控制台中自動記錄裝置程式代碼資訊和驗證指示。

userPromptCallback?: DeviceCodePromptCallback

屬性值

繼承的屬性詳細資料

additionallyAllowedTenants

針對多租使用者應用程式,指定認證可能會取得令牌的其他租使用者。 新增通配符值 「*」,以允許認證取得安裝應用程式的任何租使用者令牌。

additionallyAllowedTenants?: string[]

屬性值

string[]

繼承自InteractiveCredentialOptions.additionallyAllowedTenants

additionalPolicies

要包含在 HTTP 管線中的其他原則。

additionalPolicies?: AdditionalPolicyConfig[]

屬性值

繼承自InteractiveCredentialOptions.additionalPolicies

allowInsecureConnection

如果要求是透過 HTTP 傳送,而不是 HTTPS,請將 設定為 true

allowInsecureConnection?: boolean

屬性值

boolean

繼承自InteractiveCredentialOptions.allowInsecureConnection

authenticationRecord

先前驗證的結果,可用來擷取每個個別帳戶的快取認證。 如果應用程式想要針對每個用戶端標識碼和租使用者標識碼配對使用一個以上的帳戶,就必須提供此功能。

您可以藉由呼叫認證 authenticate() 的方法來擷取此記錄,如下所示:

const authenticationRecord = await credential.authenticate();
authenticationRecord?: AuthenticationRecord

屬性值

繼承自InteractiveCredentialOptions.authenticationRecord

authorityHost

用於驗證要求的授權單位主機。 可能的值可透過 AzureAuthorityHosts 取得。 預設值為 "https://login.microsoftonline.com"。

authorityHost?: string

屬性值

string

繼承自InteractiveCredentialOptions.authorityHost

disableAutomaticAuthentication

如果需要手動驗證,會擲回 getToken。 開發人員必須呼叫 authenticate() 以控制手動驗證的時機。

disableAutomaticAuthentication?: boolean

屬性值

boolean

繼承自InteractiveCredentialOptions.disableAutomaticAuthentication

disableInstanceDiscovery

欄位會決定嘗試驗證時是否執行實例探索。 將此設定為 true 會完全停用實例探索和授權單位驗證。 因此,請務必確保已設定的授權主機有效且值得信任。 這項功能適用於無法連線到元數據端點的情況,例如私人雲端或 Azure Stack。 實例探索的程式需要從 https://login.microsoft.com/ 中擷取授權單位元數據,以驗證授權單位。

disableInstanceDiscovery?: boolean

屬性值

boolean

繼承自InteractiveCredentialOptions.disableInstanceDiscovery

httpClient

將用來傳送 HTTP 要求的 HttpClient。

httpClient?: HttpClient

屬性值

繼承自InteractiveCredentialOptions.HTTPClient

loggingOptions

允許使用者設定記錄原則選項的設定、允許記錄帳戶資訊和客戶支援的個人標識資訊。

loggingOptions?: LogPolicyOptions & { allowLoggingAccountIdentifiers?: boolean, enableUnsafeSupportLogging?: boolean }

屬性值

LogPolicyOptions & { allowLoggingAccountIdentifiers?: boolean, enableUnsafeSupportLogging?: boolean }

繼承自InteractiveCredentialOptions.loggingOptions

proxyOptions

設定傳出要求的 Proxy 選項。

proxyOptions?: ProxySettings

屬性值

繼承自InteractiveCredentialOptions.proxyOptions

redirectOptions

重新導向回應處理方式的選項。

redirectOptions?: RedirectPolicyOptions

屬性值

繼承自InteractiveCredentialOptions.redirectOptions

retryOptions

控制如何重試失敗要求的選項。

retryOptions?: PipelineRetryOptions

屬性值

繼承自InteractiveCredentialOptions.retryOptions

telemetryOptions

將一般遙測和追蹤資訊設定為傳出要求的選項。

telemetryOptions?: TelemetryOptions

屬性值

繼承自InteractiveCredentialOptions.telemetryOptions

tlsOptions

設定 TLS 驗證的選項

tlsOptions?: TlsSettings

屬性值

繼承自InteractiveCredentialOptions.tlsOptions

tokenCachePersistenceOptions

如果儲存認證時) ,則提供給持續性層的選項 (。

您必須先註冊持續性提供者外掛程式。 @azure/identity-cache-persistence請參閱 NPM 上的套件。

範例:

import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";

useIdentityPlugin(cachePersistencePlugin);

async function main() {
  const credential = new DeviceCodeCredential({
    tokenCachePersistenceOptions: {
      enabled: true
    }
  });
}

main().catch((error) => {
  console.error("An error occurred:", error);
  process.exit(1);
});
tokenCachePersistenceOptions?: TokenCachePersistenceOptions

屬性值

繼承自CredentialPersistenceOptions.tokenCachePersistenceOptions

userAgentOptions

將使用者代理程式詳細數據新增至傳出要求的選項。

userAgentOptions?: UserAgentPolicyOptions

屬性值

繼承自InteractiveCredentialOptions.userAgentOptions