Class PublicClientApplicationBuilder
public sealed class PublicClientApplicationBuilder : AbstractApplicationBuilder<PublicClientApplicationBuilder>
- Inheritance
-
PublicClientApplicationBuilder
- Inherited Members
Methods
Build()
Builds an instance of IPublicClientApplication from the parameters set in the PublicClientApplicationBuilder.
public IPublicClientApplication Build()
Returns
- IPublicClientApplication
An instance of IPublicClientApplication
Exceptions
- MsalClientException
Thrown when errors occur locally in the library itself (for example, because of incorrect configuration).
Create(string)
Creates a PublicClientApplicationBuilder from a clientID. See https://aka.ms/msal-net-application-configuration
public static PublicClientApplicationBuilder Create(string clientId)
Parameters
clientId
stringClient ID (also known as App ID) of the application as registered in the application registration portal (https://aka.ms/msal-net-register-app)/.
Returns
- PublicClientApplicationBuilder
A PublicClientApplicationBuilder from which to set more parameters, and to create a public client application instance
CreateWithApplicationOptions(PublicClientApplicationOptions)
Creates a PublicClientApplicationBuilder from public client application configuration options. See https://aka.ms/msal-net-application-configuration
public static PublicClientApplicationBuilder CreateWithApplicationOptions(PublicClientApplicationOptions options)
Parameters
options
PublicClientApplicationOptionsPublic client applications configuration options
Returns
- PublicClientApplicationBuilder
A PublicClientApplicationBuilder from which to set more parameters, and to create a public client application instance
IsBrokerAvailable()
Returns true
if a broker can be used.
This method is only needed to be used in mobile scenarios which support Mobile Application Management. In other supported scenarios, use WithBroker
by itself, which will fall back to use a browser if broker is unavailable.
public bool IsBrokerAvailable()
Returns
Remarks
- On Windows, the broker (WAM) can be used on Windows 10 and is always installed. See https://aka.ms/msal-net-wam
- On Mac, Linux, and older versions of Windows a broker is not available.
- In .NET classic or .NET, install Microsoft.Identity.Client.Desktop first and call
WithDesktopFeatures()
. - In mobile apps, the device must be Intune joined and Authenticator or Company Portal must be installed. See https://aka.ms/msal-brokers
WithDefaultRedirectUri()
Configures the public client application to use the recommended reply URI for the platform. See https://aka.ms/msal-net-default-reply-uri.
Platform |
---|
.NET desktop |
For system browser on .NET Core |
public PublicClientApplicationBuilder WithDefaultRedirectUri()
Returns
- PublicClientApplicationBuilder
A PublicClientApplicationBuilder from which to set more parameters, and to create a public client application instance
WithKerberosTicketClaim(string, KerberosTicketContainer)
Sets the parameters required to get a Kerberos Ticket from Azure AD service.
public PublicClientApplicationBuilder WithKerberosTicketClaim(string servicePrincipalName, KerberosTicketContainer ticketContainer)
Parameters
servicePrincipalName
stringService principal name to get Kerberos Service Ticket.
ticketContainer
KerberosTicketContainerSpecify where the Kerberos ticket will be returned - as a claim in the ID token or as a claim in the access token. If the ticket is for the client application, use the ID token. If the ticket is for the downstream API, use the access token.
Returns
Remarks
The expiry of the Kerberos ticket is tied to the expiry of the token that contains it. MSAL provides several helper APIs to read and write Kerberos tickets from the Windows Ticket Cache - see KerberosSupplementalTicketManager.
WithOidcAuthority(string)
Adds a known authority corresponding to a generic OpenIdConnect Identity Provider. MSAL will append ".well-known/openid-configuration" to the authority and retrieve the OIDC metadata from there, to figure out the endpoints. See https://openid.net/specs/openid-connect-core-1_0.html#Terminology
public PublicClientApplicationBuilder WithOidcAuthority(string authorityUri)
Parameters
authorityUri
string
Returns
Remarks
Experimental on public clients. Do not use this method with Entra ID authorities (e.g. https://login.microsfoftonline.com/common). Use WithAuthority(string) instead.
WithParentActivityOrWindow(Func<nint>)
Sets a reference to the IntPtr to a window that triggers the browser to be shown. Used to center the browser that pop-up onto this window.
[CLSCompliant(false)]
public PublicClientApplicationBuilder WithParentActivityOrWindow(Func<nint> windowFunc)
Parameters
Returns
- PublicClientApplicationBuilder
The builder to chain the .With methods
WithWindowsBrokerOptions(WindowsBrokerOptions)
Allows customization of the Windows 10 Broker experience.
[Obsolete("This API has been replaced with WithBroker(BrokerOptions), which can be found in Microsoft.Identity.Client.Broker package. See https://aka.ms/msal-net-wam for details.", false)]
public PublicClientApplicationBuilder WithWindowsBrokerOptions(WindowsBrokerOptions options)
Parameters
options
WindowsBrokerOptions