@azure/ms-rest-nodeauth package
類別
| ApplicationTokenCertificateCredentials | |
| ApplicationTokenCredentials | |
| AzureCliCredentials |
透過 Azure CLI 擷取令牌來描述認證。 |
| DeviceTokenCredentials | |
| MSIAppServiceTokenCredentials |
提供 App Service 環境中受控服務識別令牌認證的相關信息。 |
| MSITokenCredentials |
提供受控服務識別令牌認證的相關信息。 此物件只能用來取得在 Azure 中布建且具有受控服務識別之虛擬機上的令牌。 |
| MSIVmTokenCredentials |
提供在 Azure 中布建之虛擬機上受控服務識別令牌認證的相關信息。 |
| TokenCredentialsBase | |
| UserTokenCredentials | |
介面
| AuthResponse |
描述驗證回應。 |
| AzureTokenCredentialsOptions |
描述 servicePrincipal/秘密驗證的選擇性參數。 |
| CliAccessToken |
描述從 Azure CLI 擷取的存取令牌。 |
| InteractiveLoginOptions |
描述互動式驗證的選擇性參數。 |
| LinkedSubscription |
提供驗證程式期間找到之訂用帳戶的相關信息。 此類型的結構與訂用帳戶物件不同,其方式是向 ResourceManager API 提出要求。 |
| LinkedUser |
從驗證觀點提供使用者的相關信息。 |
| ListAllSubscriptionOptions |
描述可透過 Azure CLI 列出所有訂用帳戶/帳戶時所提供的選項。 |
| LoginWithAuthFileOptions |
描述使用AuthFile 登入的選擇性參數。 |
| LoginWithUsernamePasswordOptions |
描述使用者名稱/密碼驗證的選擇性參數。 |
| MSIAppServiceOptions |
定義選擇性參數,以使用適用於AppService的 MSI 進行驗證。 |
| MSIOptions |
定義使用 MSI 進行驗證的選擇性參數。 |
| MSITokenResponse |
描述 MSITokenResponse。 |
| MSIVmOptions |
定義選擇性參數,以向虛擬機的 MSI 進行驗證。 |
類型別名
| TokenAudience | |
| UserType |
提供使用者類型的相關信息。 它目前可以是 “user” 或 “servicePrincipal”。 |
函式
| build |
建置 tenantIds 陣列。 |
| create |
|
| interactive |
提供 URL 和程式碼,這些 URL 和程式代碼需要在瀏覽器中複製並貼上,並在該處進行驗證。 如果成功,使用者將會取得 DeviceTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。 使用個人帳戶時, |
| interactive |
|
| interactive |
|
| interactive |
|
| interactive |
提供 URL 和程式碼,這些 URL 和程式代碼需要在瀏覽器中複製並貼上,並在該處進行驗證。 如果成功,使用者將會取得 DeviceTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。 使用個人帳戶時, |
| login |
使用 App Service MSI 進行驗證。 |
| login |
|
| login |
|
| login |
|
| login |
使用此方法之前,請先從 https://github.com/Azure/azure-cli/releases安裝 az cli。 然後執行
使用驗證檔案中所提供的服務主體信息進行驗證。 這個方法會將驗證檔案中的 subscriptionId 設定為 options 參數中的使用者提供的環境變數,或預設的 「AZURE_SUBSCRIPTION_ID」。 |
| login |
|
| login |
|
| login |
|
| login |
使用此方法之前,請先從 https://github.com/Azure/azure-cli/releases安裝 az cli。 然後執行
使用驗證檔案中所提供的服務主體信息進行驗證。 這個方法會將驗證檔案中的 subscriptionId 設定為 options 參數中的使用者提供的環境變數,或預設的 「AZURE_SUBSCRIPTION_ID」。 |
| login |
提供 ApplicationTokenCertificateCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。 使用個人帳戶時, |
| login |
|
| login |
|
| login |
|
| login |
提供 ApplicationTokenCertificateCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。 使用個人帳戶時, |
| login |
提供 ApplicationTokenCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。 使用個人帳戶時, |
| login |
|
| login |
|
| login |
|
| login |
提供 ApplicationTokenCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。 使用個人帳戶時, |
| login |
提供 UserTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。 這個方法僅適用於未啟用 2FA 的組織標識碼,否則請使用互動式登入。 使用個人帳戶時, |
| login |
|
| login |
|
| login |
|
| login |
提供 UserTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。 這個方法僅適用於未啟用 2FA 的組織標識碼,否則請使用互動式登入。 使用個人帳戶時, |
| login |
使用此方法之前,請先從 https://github.com/Azure/azure-cli/releases安裝 az cli。 如果您有使用 az cli 布建的 Azure 虛擬機並已啟用 MSI,則可以使用此方法從 VM 取得驗證令牌。 若要建立新的 VM,請啟用 MSI,請執行此命令:az vm create -g <resource_group_name> -n <vm_name> --assign-identity --image <os_image_name> 注意:上述命令會在主機上啟用服務端點,並具有預設埠 50342 若要在已布建的 VM 上啟用 MSI,請執行下列命令:az vm --assign-identity -g <resource_group_name> -n <vm_name> --port <custom_port_number> 若要深入瞭解此命令,請執行:az vm --assign-identity -h 使用在 Azure 虛擬機上執行的身分識別服務進行驗證。 此方法會向裝載在 VM 上的驗證服務提出要求,並取得存取令牌。 |
| login |
|
| login |
|
| login |
函式詳細資料
buildTenantList(TokenCredentialsBase, string)
建置 tenantIds 陣列。
function buildTenantList(credentials: TokenCredentialsBase, apiVersion?: string): Promise<string[]>
參數
- credentials
- TokenCredentialsBase
認證。
- apiVersion
-
string
預設值 2016-06-01
傳回
Promise<string[]>
可解析為tenantId數位並拒絕且發生錯誤的承諾。
createAuthenticator(MSITokenCredentials)
function createAuthenticator(credentials: MSITokenCredentials): Authenticator
參數
- credentials
- MSITokenCredentials
傳回
interactiveLogin()
提供 URL 和程式碼,這些 URL 和程式代碼需要在瀏覽器中複製並貼上,並在該處進行驗證。 如果成功,使用者將會取得 DeviceTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。
使用個人帳戶時,domain 參數中的 options 屬性必須設定為該帳戶租用戶的標識碼。 否則,產生的認證將無法存取帳戶的資源。
function interactiveLogin(): Promise<DeviceTokenCredentials>
傳回
Promise<DeviceTokenCredentials>
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 使用產生的 DeviceTokenCredentials 物件和所有適用的租使用者相關聯的訂用帳戶清單來呼叫回呼。
interactiveLogin(InteractiveLoginOptions)
function interactiveLogin(options: InteractiveLoginOptions): Promise<DeviceTokenCredentials>
參數
- options
- InteractiveLoginOptions
傳回
Promise<DeviceTokenCredentials>
interactiveLogin(InteractiveLoginOptions, (err: Error, credentials: DeviceTokenCredentials, subscriptions: LinkedSubscription[]) => void)
function interactiveLogin(options: InteractiveLoginOptions, callback: (err: Error, credentials: DeviceTokenCredentials, subscriptions: LinkedSubscription[]) => void)
參數
- options
- InteractiveLoginOptions
- callback
-
(err: Error, credentials: DeviceTokenCredentials, subscriptions: LinkedSubscription[]) => void
interactiveLogin(any)
function interactiveLogin(callback: any)
參數
- callback
-
any
interactiveLoginWithAuthResponse(InteractiveLoginOptions)
提供 URL 和程式碼,這些 URL 和程式代碼需要在瀏覽器中複製並貼上,並在該處進行驗證。 如果成功,使用者將會取得 DeviceTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。
使用個人帳戶時,domain 參數中的 options 屬性必須設定為該帳戶租用戶的標識碼。 否則,產生的認證將無法存取帳戶的資源。
function interactiveLoginWithAuthResponse(options?: InteractiveLoginOptions): Promise<AuthResponse<DeviceTokenCredentials>>
參數
- options
- InteractiveLoginOptions
物件,表示選擇性參數。
傳回
Promise<AuthResponse<DeviceTokenCredentials>>
解析為 AuthResponse 的 Promise,其中包含「認證」和選擇性「訂用帳戶」陣列,並拒絕並出現錯誤。
loginWithAppServiceMSI()
使用 App Service MSI 進行驗證。
function loginWithAppServiceMSI(): Promise<MSIAppServiceTokenCredentials>
傳回
Promise<MSIAppServiceTokenCredentials>
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 使用產生的 MSIAppServiceTokenCredentials 物件呼叫回呼。
loginWithAppServiceMSI(MSIAppServiceOptions)
function loginWithAppServiceMSI(options: MSIAppServiceOptions): Promise<MSIAppServiceTokenCredentials>
參數
- options
- MSIAppServiceOptions
傳回
Promise<MSIAppServiceTokenCredentials>
loginWithAppServiceMSI(MSIAppServiceOptions, Callback<MSIAppServiceTokenCredentials>)
function loginWithAppServiceMSI(options: MSIAppServiceOptions, callback: Callback<MSIAppServiceTokenCredentials>)
參數
- options
- MSIAppServiceOptions
- callback
-
Callback<MSIAppServiceTokenCredentials>
loginWithAppServiceMSI(Callback<MSIAppServiceTokenCredentials>)
function loginWithAppServiceMSI(callback: Callback<MSIAppServiceTokenCredentials>)
參數
- callback
-
Callback<MSIAppServiceTokenCredentials>
loginWithAuthFile()
使用此方法之前,請先從 https://github.com/Azure/azure-cli/releases安裝 az cli。 然後執行 az ad sp create-for-rbac --sdk-auth > ${yourFilename.json}。
如果您想要為不同的雲端/環境建立sp,請執行:
- az 雲清單
- az cloud set –n <環境的名稱>
- az ad sp create-for-rbac --sdk-auth > auth.json -- 使用機密創建 SP 或
- az ad sp create-for-rbac --create-cert --sdk-auth > auth.json // create sp with certificate If the service principal is created then login with service principal info:
- az login --service-principal -u <clientId> -p <clientSecret> -t <tenantId>
- az account show --sdk-auth > auth.json
使用驗證檔案中所提供的服務主體信息進行驗證。 這個方法會將驗證檔案中的 subscriptionId 設定為 options 參數中的使用者提供的環境變數,或預設的 「AZURE_SUBSCRIPTION_ID」。
function loginWithAuthFile(): Promise<ApplicationTokenCredentials | ApplicationTokenCertificateCredentials>
傳回
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 呼叫回呼時,會產生ApplicationTokenCredentials或ApplicationTokenCertificateCredentials物件,以及所有適用租使用者之間的相關聯訂用帳戶清單。
loginWithAuthFile(LoginWithAuthFileOptions)
function loginWithAuthFile(options: LoginWithAuthFileOptions): Promise<ApplicationTokenCredentials | ApplicationTokenCertificateCredentials>
參數
- options
- LoginWithAuthFileOptions
傳回
loginWithAuthFile(LoginWithAuthFileOptions, (err: Error, credentials: ApplicationTokenCredentials | ApplicationTokenCertificateCredentials, subscriptions: LinkedSubscription[]) => void)
function loginWithAuthFile(options: LoginWithAuthFileOptions, callback: (err: Error, credentials: ApplicationTokenCredentials | ApplicationTokenCertificateCredentials, subscriptions: LinkedSubscription[]) => void)
參數
- options
- LoginWithAuthFileOptions
- callback
-
(err: Error, credentials: ApplicationTokenCredentials | ApplicationTokenCertificateCredentials, subscriptions: LinkedSubscription[]) => void
loginWithAuthFile(any)
function loginWithAuthFile(callback: any)
參數
- callback
-
any
loginWithAuthFileWithAuthResponse(LoginWithAuthFileOptions)
使用此方法之前,請先從 https://github.com/Azure/azure-cli/releases安裝 az cli。 然後執行 az ad sp create-for-rbac --sdk-auth > ${yourFilename.json}。
如果您想要為不同的雲端/環境建立sp,請執行:
- az 雲清單
- az cloud set –n <環境的名稱>
- az ad sp create-for-rbac --sdk-auth > auth.json -- 使用機密創建 SP 或
- az ad sp create-for-rbac --create-cert --sdk-auth > auth.json // create sp with certificate If the service principal is created then login with service principal info:
- az login --service-principal -u <clientId> -p <clientSecret> -t <tenantId>
- az account show --sdk-auth > auth.json
使用驗證檔案中所提供的服務主體信息進行驗證。 這個方法會將驗證檔案中的 subscriptionId 設定為 options 參數中的使用者提供的環境變數,或預設的 「AZURE_SUBSCRIPTION_ID」。
function loginWithAuthFileWithAuthResponse(options?: LoginWithAuthFileOptions): Promise<AuthResponse<ApplicationTokenCredentials | ApplicationTokenCertificateCredentials>>
參數
- options
- LoginWithAuthFileOptions
選擇性參數
傳回
解析為 AuthResponse 的 Promise,其中包含「認證」和選擇性「訂用帳戶」陣列,並拒絕並出現錯誤。
loginWithServicePrincipalCertificate(string, string, string)
提供 ApplicationTokenCertificateCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。
使用個人帳戶時,domain 參數必須設定為該帳戶租用戶的標識符。 否則,產生的認證將無法存取帳戶的資源。
function loginWithServicePrincipalCertificate(clientId: string, certificateStringOrFilePath: string, domain: string): Promise<ApplicationTokenCertificateCredentials>
參數
- clientId
-
string
Active Directory 應用程式用戶端標識碼也稱為 SPN (ServicePrincipal Name)。 如需範例,請參閱 .Net 的 Active Directory 快速入門。
- certificateStringOrFilePath
-
string
PEM 編碼的憑證和私鑰,或包含該資訊的 .pem 檔案的絕對檔案路徑。 例如:
- CertificateString: “-----BEGIN PRIVATE KEY <-----\nxxxxx>\n----- END PRIVATE KEY-----\n-----BEGIN CERTIFICATE <-----\nyyyyy>\n----- END CERTIFICATE-----\n”
- CertificateFilePath:.pem 檔案的絕對 檔案路徑。
- domain
-
string
包含此應用程式的網域或租用戶標識碼。
傳回
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 呼叫回呼時,會產生ApplicationTokenCertificateCredentials物件,以及所有適用租使用者的相關聯訂用帳戶清單。
loginWithServicePrincipalCertificate(string, string, string, AzureTokenCredentialsOptions)
function loginWithServicePrincipalCertificate(clientId: string, certificateStringOrFilePath: string, domain: string, options: AzureTokenCredentialsOptions): Promise<ApplicationTokenCertificateCredentials>
參數
- clientId
-
string
- certificateStringOrFilePath
-
string
- domain
-
string
- options
- AzureTokenCredentialsOptions
傳回
loginWithServicePrincipalCertificate(string, string, string, AzureTokenCredentialsOptions, (err: Error, credentials: ApplicationTokenCertificateCredentials, subscriptions: LinkedSubscription[]) => void)
function loginWithServicePrincipalCertificate(clientId: string, certificateStringOrFilePath: string, domain: string, options: AzureTokenCredentialsOptions, callback: (err: Error, credentials: ApplicationTokenCertificateCredentials, subscriptions: LinkedSubscription[]) => void)
參數
- clientId
-
string
- certificateStringOrFilePath
-
string
- domain
-
string
- options
- AzureTokenCredentialsOptions
- callback
-
(err: Error, credentials: ApplicationTokenCertificateCredentials, subscriptions: LinkedSubscription[]) => void
loginWithServicePrincipalCertificate(string, string, string, any)
function loginWithServicePrincipalCertificate(clientId: string, certificateStringOrFilePath: string, domain: string, callback: any)
參數
- clientId
-
string
- certificateStringOrFilePath
-
string
- domain
-
string
- callback
-
any
loginWithServicePrincipalCertificateWithAuthResponse(string, string, string, AzureTokenCredentialsOptions)
提供 ApplicationTokenCertificateCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。
使用個人帳戶時,domain 參數必須設定為該帳戶租用戶的標識符。 否則,產生的認證將無法存取帳戶的資源。
function loginWithServicePrincipalCertificateWithAuthResponse(clientId: string, certificateStringOrFilePath: string, domain: string, options?: AzureTokenCredentialsOptions): Promise<AuthResponse<ApplicationTokenCertificateCredentials>>
參數
- clientId
-
string
Active Directory 應用程式用戶端標識碼也稱為 SPN (ServicePrincipal Name)。 如需範例,請參閱 .Net 的 Active Directory 快速入門。
- certificateStringOrFilePath
-
string
PEM 編碼的憑證和私鑰,或包含該資訊的 .pem 檔案的絕對檔案路徑。 例如:
- CertificateString: “-----BEGIN PRIVATE KEY <-----\nxxxxx>\n----- END PRIVATE KEY-----\n-----BEGIN CERTIFICATE <-----\nyyyyy>\n----- END CERTIFICATE-----\n”
- CertificateFilePath:.pem 檔案的絕對 檔案路徑。
- domain
-
string
包含此應用程式的網域或租用戶標識碼。
- options
- AzureTokenCredentialsOptions
物件,表示選擇性參數。
傳回
解析為 AuthResponse 的 Promise,其中包含「認證」和選擇性「訂用帳戶」陣列,並拒絕並出現錯誤。
loginWithServicePrincipalSecret(string, string, string)
提供 ApplicationTokenCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。
使用個人帳戶時,domain 參數必須設定為該帳戶租用戶的標識符。 否則,產生的認證將無法存取帳戶的資源。
function loginWithServicePrincipalSecret(clientId: string, secret: string, domain: string): Promise<ApplicationTokenCredentials>
參數
- clientId
-
string
Active Directory 應用程式用戶端標識碼也稱為 SPN (ServicePrincipal Name)。 如需範例,請參閱 .Net 的 Active Directory 快速入門。
- secret
-
string
服務主體的應用程式密碼。
- domain
-
string
包含此應用程式的網域或租用戶標識碼。
傳回
Promise<ApplicationTokenCredentials>
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 使用產生的ApplicationTokenCredentials物件和所有適用的租使用者相關聯的訂用帳戶清單來呼叫回呼。
loginWithServicePrincipalSecret(string, string, string, AzureTokenCredentialsOptions)
function loginWithServicePrincipalSecret(clientId: string, secret: string, domain: string, options: AzureTokenCredentialsOptions): Promise<ApplicationTokenCredentials>
參數
- clientId
-
string
- secret
-
string
- domain
-
string
- options
- AzureTokenCredentialsOptions
傳回
Promise<ApplicationTokenCredentials>
loginWithServicePrincipalSecret(string, string, string, AzureTokenCredentialsOptions, (err: Error, credentials: ApplicationTokenCredentials, subscriptions: LinkedSubscription[]) => void)
function loginWithServicePrincipalSecret(clientId: string, secret: string, domain: string, options: AzureTokenCredentialsOptions, callback: (err: Error, credentials: ApplicationTokenCredentials, subscriptions: LinkedSubscription[]) => void)
參數
- clientId
-
string
- secret
-
string
- domain
-
string
- options
- AzureTokenCredentialsOptions
- callback
-
(err: Error, credentials: ApplicationTokenCredentials, subscriptions: LinkedSubscription[]) => void
loginWithServicePrincipalSecret(string, string, string, any)
function loginWithServicePrincipalSecret(clientId: string, secret: string, domain: string, callback: any)
參數
- clientId
-
string
- secret
-
string
- domain
-
string
- callback
-
any
loginWithServicePrincipalSecretWithAuthResponse(string, string, string, AzureTokenCredentialsOptions)
提供 ApplicationTokenCredentials 物件,以及所有適用租使用者中與該服務PrincipalId/clientId 相關聯的訂用帳戶清單。
使用個人帳戶時,domain 參數必須設定為該帳戶租用戶的標識符。 否則,產生的認證將無法存取帳戶的資源。
function loginWithServicePrincipalSecretWithAuthResponse(clientId: string, secret: string, domain: string, options?: AzureTokenCredentialsOptions): Promise<AuthResponse<ApplicationTokenCredentials>>
參數
- clientId
-
string
Active Directory 應用程式用戶端標識碼也稱為 SPN (ServicePrincipal Name)。 如需範例,請參閱 .Net 的 Active Directory 快速入門。
- secret
-
string
服務主體的應用程式密碼。
- domain
-
string
包含此應用程式的網域或租用戶標識碼。
- options
- AzureTokenCredentialsOptions
物件,表示選擇性參數。
傳回
Promise<AuthResponse<ApplicationTokenCredentials>>
解析為 AuthResponse 的 Promise,其中包含「認證」和選擇性「訂用帳戶」陣列,並拒絕並出現錯誤。
loginWithUsernamePassword(string, string)
提供 UserTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。
這個方法僅適用於未啟用 2FA 的組織標識碼,否則請使用互動式登入。
使用個人帳戶時,domain 參數中的 options 屬性必須設定為該帳戶租用戶的標識碼。 否則,產生的認證將無法存取帳戶的資源。
function loginWithUsernamePassword(username: string, password: string): Promise<UserTokenCredentials>
參數
- username
-
string
組織標識元帳戶的用戶名稱。
- password
-
string
組織標識子帳戶的密碼。
傳回
Promise<UserTokenCredentials>
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 使用產生的 UserTokenCredentials 物件和所有適用租使用者相關聯的訂用帳戶清單來呼叫回呼。
loginWithUsernamePassword(string, string, LoginWithUsernamePasswordOptions)
function loginWithUsernamePassword(username: string, password: string, options: LoginWithUsernamePasswordOptions): Promise<UserTokenCredentials>
參數
- username
-
string
- password
-
string
- options
- LoginWithUsernamePasswordOptions
傳回
Promise<UserTokenCredentials>
loginWithUsernamePassword(string, string, any)
function loginWithUsernamePassword(username: string, password: string, callback: any)
參數
- username
-
string
- password
-
string
- callback
-
any
loginWithUsernamePassword(string, string, LoginWithUsernamePasswordOptions, (err: Error, credentials: UserTokenCredentials, subscriptions: LinkedSubscription[]) => void)
function loginWithUsernamePassword(username: string, password: string, options: LoginWithUsernamePasswordOptions, callback: (err: Error, credentials: UserTokenCredentials, subscriptions: LinkedSubscription[]) => void)
參數
- username
-
string
- password
-
string
- options
- LoginWithUsernamePasswordOptions
- callback
-
(err: Error, credentials: UserTokenCredentials, subscriptions: LinkedSubscription[]) => void
loginWithUsernamePasswordWithAuthResponse(string, string, LoginWithUsernamePasswordOptions)
提供 UserTokenCredentials 物件,以及所有適用租使用者中與該 userId 相關聯的訂用帳戶清單。 這個方法僅適用於未啟用 2FA 的組織標識碼,否則請使用互動式登入。
使用個人帳戶時,domain 參數中的 options 屬性必須設定為該帳戶租用戶的標識碼。 否則,產生的認證將無法存取帳戶的資源。
function loginWithUsernamePasswordWithAuthResponse(username: string, password: string, options?: LoginWithUsernamePasswordOptions): Promise<AuthResponse<UserTokenCredentials>>
參數
- username
-
string
組織標識元帳戶的用戶名稱。
- password
-
string
組織標識子帳戶的密碼。
- options
- LoginWithUsernamePasswordOptions
物件,表示選擇性參數。
傳回
Promise<AuthResponse<UserTokenCredentials>>
解析為 AuthResponse 的 Promise,其中包含 credentials 和選擇性 subscriptions 陣列,並拒絕錯誤。
loginWithVmMSI()
使用此方法之前,請先從 https://github.com/Azure/azure-cli/releases安裝 az cli。 如果您有使用 az cli 布建的 Azure 虛擬機並已啟用 MSI,則可以使用此方法從 VM 取得驗證令牌。
若要建立新的 VM,請啟用 MSI,請執行此命令:az vm create -g <resource_group_name> -n <vm_name> --assign-identity --image <os_image_name> 注意:上述命令會在主機上啟用服務端點,並具有預設埠 50342
若要在已布建的 VM 上啟用 MSI,請執行下列命令:az vm --assign-identity -g <resource_group_name> -n <vm_name> --port <custom_port_number>
若要深入瞭解此命令,請執行:az vm --assign-identity -h
使用在 Azure 虛擬機上執行的身分識別服務進行驗證。 此方法會向裝載在 VM 上的驗證服務提出要求,並取得存取令牌。
function loginWithVmMSI(): Promise<MSIVmTokenCredentials>
傳回
Promise<MSIVmTokenCredentials>
如果回呼傳遞為最後一個參數,則會傳回 void,否則會傳回 Promise。 使用產生的 MSIVmTokenCredentials 物件呼叫回呼。
loginWithVmMSI(MSIVmOptions)
function loginWithVmMSI(options: MSIVmOptions): Promise<MSIVmTokenCredentials>
參數
- options
- MSIVmOptions
傳回
Promise<MSIVmTokenCredentials>
loginWithVmMSI(MSIVmOptions, Callback<MSIVmTokenCredentials>)
function loginWithVmMSI(options: MSIVmOptions, callback: Callback<MSIVmTokenCredentials>)
參數
- options
- MSIVmOptions
- callback
-
Callback<MSIVmTokenCredentials>
loginWithVmMSI(Callback<MSIVmTokenCredentials>)
function loginWithVmMSI(callback: Callback<MSIVmTokenCredentials>)
參數
- callback
-
Callback<MSIVmTokenCredentials>
Variable Details
AuthConstants
AuthConstants: { AAD_COMMON_TENANT: string, AZURE_AUTH_LOCATION: string, DEFAULT_ADAL_CLIENT_ID: string, DEFAULT_LANGUAGE: string, RESOURCE_MANAGER_ENDPOINT: string, SDK_INTERNAL_ERROR: string }
類型
{ AAD_COMMON_TENANT: string, AZURE_AUTH_LOCATION: string, DEFAULT_ADAL_CLIENT_ID: string, DEFAULT_LANGUAGE: string, RESOURCE_MANAGER_ENDPOINT: string, SDK_INTERNAL_ERROR: string }