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

ClientCertificateCredential class

允许使用分配给应用注册的 PEM 编码证书Microsoft Entra ID 进行身份验证。 有关如何配置证书身份验证的详细信息,可在此处找到:

https://learn.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad

构造函数

ClientCertificateCredential(string, string, ClientCertificatePEMCertificate, ClientCertificateCredentialOptions)

使用证书对 Microsoft Entra ID 进行身份验证所需的详细信息创建 ClientCertificateCredential 的实例。

ClientCertificateCredential(string, string, ClientCertificatePEMCertificatePath, ClientCertificateCredentialOptions)

使用证书对 Microsoft Entra ID 进行身份验证所需的详细信息创建 ClientCertificateCredential 的实例。

ClientCertificateCredential(string, string, string, ClientCertificateCredentialOptions)

使用证书对 Microsoft Entra ID 进行身份验证所需的详细信息创建 ClientCertificateCredential 的实例。

方法

getToken(string | string[], GetTokenOptions)

使用 Microsoft Entra ID 进行身份验证,如果成功,则返回访问令牌。 如果身份验证失败,则会引发 CredentialUnavailableError,其中包含失败的详细信息。

构造函数详细信息

ClientCertificateCredential(string, string, ClientCertificatePEMCertificate, ClientCertificateCredentialOptions)

使用证书对 Microsoft Entra ID 进行身份验证所需的详细信息创建 ClientCertificateCredential 的实例。

new ClientCertificateCredential(tenantId: string, clientId: string, configuration: ClientCertificatePEMCertificate, options?: ClientCertificateCredentialOptions)

参数

tenantId

string

Microsoft Entra 租户(目录)ID。

clientId

string

租户中应用注册的客户端(应用程序)ID。

configuration
ClientCertificatePEMCertificate

需要其他参数,包括 PEM 编码的证书作为字符串。 如果忽略类型,我们将引发 PEM 编码证书的值。

options
ClientCertificateCredentialOptions

用于配置发出身份验证请求的客户端的选项。

ClientCertificateCredential(string, string, ClientCertificatePEMCertificatePath, ClientCertificateCredentialOptions)

使用证书对 Microsoft Entra ID 进行身份验证所需的详细信息创建 ClientCertificateCredential 的实例。

new ClientCertificateCredential(tenantId: string, clientId: string, configuration: ClientCertificatePEMCertificatePath, options?: ClientCertificateCredentialOptions)

参数

tenantId

string

Microsoft Entra 租户(目录)ID。

clientId

string

租户中应用注册的客户端(应用程序)ID。

configuration
ClientCertificatePEMCertificatePath

所需的其他参数,包括文件系统上的证书路径。 如果忽略类型,我们将引发 PEM 证书路径的值。

options
ClientCertificateCredentialOptions

用于配置发出身份验证请求的客户端的选项。

ClientCertificateCredential(string, string, string, ClientCertificateCredentialOptions)

使用证书对 Microsoft Entra ID 进行身份验证所需的详细信息创建 ClientCertificateCredential 的实例。

new ClientCertificateCredential(tenantId: string, clientId: string, certificatePath: string, options?: ClientCertificateCredentialOptions)

参数

tenantId

string

Microsoft Entra 租户(目录)ID。

clientId

string

租户中应用注册的客户端(应用程序)ID。

certificatePath

string

文件系统上 PEM 编码的公钥/私钥证书的路径。 确保证书采用 PEM 格式,并同时包含公钥和私钥。

options
ClientCertificateCredentialOptions

用于配置发出身份验证请求的客户端的选项。

方法详细信息

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>