你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

MSIAppServiceTokenCredentials class

提供有关应用服务环境中的托管服务标识令牌凭据的信息。

扩展

构造函数

MSIAppServiceTokenCredentials(MSIAppServiceOptions)

创建 MSIAppServiceTokenCredentials 的实例。

属性

clientId

要为其指定令牌的托管标识的 clientId。 如果应用服务具有用户分配的托管标识,则为必需。

msiApiVersion

本地 MSI 代理的 API 版本。 默认值为“2017-09-01”。

msiEndpoint

应用可从中请求令牌的本地 URL。 除非指定此属性,否则 IDENTITY_ENDPOINTMSI_ENDPOINT 的两个环境变量中的任何一个都将用作默认值。

msiSecret

代码与本地 MSI 代理之间通信时使用的机密。 除非指定此属性,否则 IDENTITY_SECRETMSI_SECRET 的两个环境变量中的任何一个都将用作默认值。

继承属性

resource

Azure 资源终结点。

  • 默认为环境中的 Azure 资源管理器:AzureCloud。 “https://management.azure.com/"
  • 对于 ServiceManagement(ASM):“https://management.core.windows.net/"
  • 对于 Azure KeyVault:“https://vault.azure.net"
  • 对于 Azure Batch:“https://batch.core.windows.net"
  • 对于 Azure Active Directory Graph:“https://graph.windows.net"

方法

getToken()

准备 GET 请求并将其发送到应用服务指示的服务终结点,该终结点使用访问令牌进行响应。

继承的方法

parseTokenResponse(string)

将 tokenResponse json 字符串分析为对象,并将第一个级别的属性转换为 camelCase。 此方法尝试标准化 tokenResponse

signRequest(WebResource)

使用身份验证标头对请求进行签名。

构造函数详细信息

MSIAppServiceTokenCredentials(MSIAppServiceOptions)

创建 MSIAppServiceTokenCredentials 的实例。

new MSIAppServiceTokenCredentials(options?: MSIAppServiceOptions)

参数

属性详细信息

clientId

要为其指定令牌的托管标识的 clientId。 如果应用服务具有用户分配的托管标识,则为必需。

clientId?: string

属性值

string

msiApiVersion

本地 MSI 代理的 API 版本。 默认值为“2017-09-01”。

msiApiVersion?: string

属性值

string

msiEndpoint

应用可从中请求令牌的本地 URL。 除非指定此属性,否则 IDENTITY_ENDPOINTMSI_ENDPOINT 的两个环境变量中的任何一个都将用作默认值。

msiEndpoint: string

属性值

string

msiSecret

代码与本地 MSI 代理之间通信时使用的机密。 除非指定此属性,否则 IDENTITY_SECRETMSI_SECRET 的两个环境变量中的任何一个都将用作默认值。

msiSecret: string

属性值

string

继承属性详细信息

resource

Azure 资源终结点。

  • 默认为环境中的 Azure 资源管理器:AzureCloud。 “https://management.azure.com/"
  • 对于 ServiceManagement(ASM):“https://management.core.windows.net/"
  • 对于 Azure KeyVault:“https://vault.azure.net"
  • 对于 Azure Batch:“https://batch.core.windows.net"
  • 对于 Azure Active Directory Graph:“https://graph.windows.net"
resource: string

属性值

string

继承自MSITokenCredentials.resource

方法详细信息

getToken()

准备 GET 请求并将其发送到应用服务指示的服务终结点,该终结点使用访问令牌进行响应。

function getToken(): Promise<MSITokenResponse>

返回

Promise<MSITokenResponse>

tokenResponse 的 Promise(tokenType 和 accessToken 是两个重要属性)。

继承的方法详细信息

parseTokenResponse(string)

将 tokenResponse json 字符串分析为对象,并将第一个级别的属性转换为 camelCase。 此方法尝试标准化 tokenResponse

function parseTokenResponse(body: string): TokenResponse

参数

body

string

json 字符串

返回

TokenResponse

tokenResponse (tokenType 和 accessToken 是两个重要属性)。

继承自MSITokenCredentials.parseTokenResponse

signRequest(WebResource)

使用身份验证标头对请求进行签名。

function signRequest(webResource: WebResource): Promise<WebResource>

参数

webResource
WebResource

要签名的 WebResource。

返回

Promise<WebResource>

具有已签名 WebResource 的承诺。

继承自MSITokenCredentials.signRequest