Class AcquireTokenInteractiveParameterBuilder
Builder for an Interactive token request. See https://aka.ms/msal-net-acquire-token-interactively
public sealed class AcquireTokenInteractiveParameterBuilder : AbstractPublicClientAcquireTokenParameterBuilder<AcquireTokenInteractiveParameterBuilder>
- Inheritance
-
AcquireTokenInteractiveParameterBuilder
- Inherited Members
- Extension Methods
Methods
Validate()
Validates the parameters of the AcquireToken operation.
protected override void Validate()
WithAccount(IAccount)
Sets the account for which the token will be retrieved. This method is mutually exclusive with WithLoginHint(string). If both are used, an exception will be thrown
public AcquireTokenInteractiveParameterBuilder WithAccount(IAccount account)
Parameters
account
IAccountAccount to use for the interactive token acquisition. See IAccount for ways to get an account
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithEmbeddedWebViewOptions(EmbeddedWebViewOptions)
Specifies options for using the embedded web view for interactive authentication.
public AcquireTokenInteractiveParameterBuilder WithEmbeddedWebViewOptions(EmbeddedWebViewOptions options)
Parameters
options
EmbeddedWebViewOptionsData object with options
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithExtraScopesToConsent(IEnumerable<string>)
public AcquireTokenInteractiveParameterBuilder WithExtraScopesToConsent(IEnumerable<string> extraScopesToConsent)
Parameters
extraScopesToConsent
IEnumerable<string>Scopes that you can request the end user to consent upfront, in addition to the scopes for the protected Web API for which you want to acquire a security token.
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithLoginHint(string)
Sets the loginHint
, in order to avoid select account
dialogs in the case the user is signed-in with several identities. This method is mutually exclusive
with WithAccount(IAccount). If both are used, an exception will be thrown
public AcquireTokenInteractiveParameterBuilder WithLoginHint(string loginHint)
Parameters
loginHint
stringIdentifier of the user. Generally in UserPrincipalName (UPN) format, e.g.
john.doe@contoso.com
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithParentActivityOrWindow(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. The center of the screen or the foreground app if a value is configured.
[CLSCompliant(false)]
public AcquireTokenInteractiveParameterBuilder WithParentActivityOrWindow(nint window)
Parameters
window
nintThe current window as IntPtr
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithPrompt(Prompt)
Specifies the what the interactive experience is for the user.
public AcquireTokenInteractiveParameterBuilder WithPrompt(Prompt prompt)
Parameters
prompt
PromptRequested interactive experience. The default is SelectAccount
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithProofOfPossession(string, HttpMethod, Uri)
Modifies the token acquisition request so that the acquired token is a Proof-of-Possession token (PoP), rather than a Bearer token. PoP tokens are similar to Bearer tokens, but are bound to the HTTP request and to a cryptographic key, which MSAL can manage on Windows. Note that only the host and path parts of the request URI will be bound. See https://aka.ms/msal-net-pop
public AcquireTokenInteractiveParameterBuilder WithProofOfPossession(string nonce, HttpMethod httpMethod, Uri requestUri)
Parameters
nonce
stringNonce of the protected resource which will be published as part of the WWW-Authenticate header associated with a 401 HTTP response or as part of the AuthorityInfo header associated with 200 response. Set it here to make it part of the Signed HTTP Request part of the PoP token.
httpMethod
HttpMethodThe HTTP method ("GET", "POST" etc.) method that will be bound to the token. If set to null, the PoP token will not be bound to the method. Corresponds to the "m" part of the a signed HTTP request.
requestUri
UriThe URI to bind the signed HTTP request to.
Returns
- AcquireTokenInteractiveParameterBuilder
The builder.
Remarks
- An Authentication header is automatically added to the request.
- The PoP token is bound to the HTTP request, more specifically to the HTTP method (GET, POST, etc.) and to the Uri (path and query, but not query parameters).
- Broker is required to use Proof-of-Possession on public clients.
WithSystemWebViewOptions(SystemWebViewOptions)
Specifies options for using the system OS browser handle interactive authentication.
public AcquireTokenInteractiveParameterBuilder WithSystemWebViewOptions(SystemWebViewOptions options)
Parameters
options
SystemWebViewOptionsData object with options
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods
WithUseEmbeddedWebView(bool)
Specifies if the public client application should used an embedded web browser or the system default browser. If the broker (WAM, Authenticator, Company Portal) is configured, this setting is only used when the broker is not installed.
On .NET, including net8-windows, app developers must reference Microsoft.Identity.Client.Desktop and call PublicClientApplicationBuilder.WithDesktopFeatures() to enable the embedded web browser.
public AcquireTokenInteractiveParameterBuilder WithUseEmbeddedWebView(bool useEmbeddedWebView)
Parameters
useEmbeddedWebView
boolIf
true
, will use an embedded web browser, otherwise will attempt to use a system web browser. The default depends on the platform:false
for iOS and Android, andtrue
for .NET Framework
Returns
- AcquireTokenInteractiveParameterBuilder
The builder to chain the .With methods