ITokenAcquirer.GetTokenForAppAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Acquires an authentication result from the authority configured in the app, for the confidential client itself (not on behalf of a user) using the client credentials flow. See https://aka.ms/msal-net-client-credentials.
public System.Threading.Tasks.Task<Microsoft.Identity.Abstractions.AcquireTokenResult> GetTokenForAppAsync (string scope, Microsoft.Identity.Abstractions.AcquireTokenOptions? tokenAcquisitionOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetTokenForAppAsync : string * Microsoft.Identity.Abstractions.AcquireTokenOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Identity.Abstractions.AcquireTokenResult>
Public Function GetTokenForAppAsync (scope As String, Optional tokenAcquisitionOptions As AcquireTokenOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AcquireTokenResult)
Parameters
- scope
- String
The scope requested to access a protected API. For this flow (client credentials), the scope
should be of the form "{ResourceIdUri/.default}" for instance https://management.azure.net/.default
or, for Microsoft
Graph, https://graph.microsoft.com/.default
as the requested scopes are defined statically with the application registration
in the portal, and cannot be overridden in the application, as you can request a token for only one resource at a time (use
several calls to get tokens for other resources).
- tokenAcquisitionOptions
- AcquireTokenOptions
Options passed-in to create the token acquisition object which calls into MSAL .NET.
- cancellationToken
- CancellationToken
Cancellation token
Returns
An authentication result for the app itself, based on its scopes.