共用方式為


OnBehalfOfCredential Class

  • java.lang.Object
    • com.azure.identity.OnBehalfOfCredential

Implements

public class OnBehalfOfCredential
implements TokenCredential

On Behalf of authentication in Azure is a way for a user or application to authenticate to a service or resource using credentials from another identity provider. This type of authentication is typically used when a user or application wants to access a resource in Azure, but their credentials are managed by a different identity provider, such as an on-premises Active Directory or a third-party identity provider. To use "On Behalf of" authentication in Azure, the user must first authenticate to the identity provider using their credentials. The identity provider then issues a security token that contains information about the user and their permissions. This security token is then passed to Azure, which uses it to authenticate the user or application and grant them access to the requested resource. The OnBehalfOfCredential acquires a token with a client secret/certificate and user assertion for a Microsoft Entra application on behalf of a user principal.

The following code sample demonstrates the creation of a OnBehalfOfCredential, using the OnBehalfOfCredentialBuilder to configure it. The tenantId, clientId and clientSecret parameters are required to create OnBehalfOfCredential. The userAssertion can be optionally specified on the OnBehalfOfCredentialBuilder. Once this credential is created, it may be passed into the builder of many of the Azure SDK for Java client builders as the 'credential' parameter.

TokenCredential onBehalfOfCredential = new OnBehalfOfCredentialBuilder().clientId("<app-client-ID>")
     .clientSecret("<app-Client-Secret>")
     .tenantId("<app-tenant-ID>")
     .userAssertion("<user-assertion>")
     .build();

Method Summary

Modifier and Type Method and Description
Mono<AccessToken> getToken(TokenRequestContext request)
AccessToken getTokenSync(TokenRequestContext request)

Methods inherited from java.lang.Object

Method Details

getToken

public Mono getToken(TokenRequestContext request)

Parameters:

request

getTokenSync

public AccessToken getTokenSync(TokenRequestContext request)

Parameters:

request

Applies to