Interface ILongRunningWebApi
Methods for long-running or background processes in web APIs.
public interface ILongRunningWebApi
- Extension Methods
Methods
AcquireTokenInLongRunningProcess(IEnumerable<string>, string)
Retrieves an access token from the cache using the provided cache key that can be used to access another downstream protected web API on behalf of a user using the OAuth 2.0 On-Behalf-Of flow. See Long-running OBO in MSAL.NET. Use StopLongRunningProcessInWebApiAsync(ILongRunningWebApi, string, CancellationToken) to stop the long running process and remove the associated tokens from the cache.
AcquireTokenOnBehalfOfParameterBuilder AcquireTokenInLongRunningProcess(IEnumerable<string> scopes, string longRunningProcessSessionKey)
Parameters
scopes
IEnumerable<string>Scopes requested to access a protected API.
longRunningProcessSessionKey
stringKey by which to look up the token in the cache.
Returns
- AcquireTokenOnBehalfOfParameterBuilder
A builder enabling you to add other parameters before executing the token request.
Remarks
This method should be called during the long-running session to retrieve the token from the cache.
Exceptions
- MsalClientException
The token cache does not contain a token with an OBO cache key that matches the
longRunningProcessSessionKey
.
InitiateLongRunningProcessInWebApi(IEnumerable<string>, string, ref string)
Acquires an access token for this web API from the authority configured in the application,
in order to access another downstream protected web API on behalf of a user using the OAuth 2.0 On-Behalf-Of flow.
See Long-running OBO in MSAL.NET.
Pass an access token (not an ID token) which was used to call this confidential client application in the
userToken
parameter.
Use StopLongRunningProcessInWebApiAsync(ILongRunningWebApi, string, CancellationToken) to stop the long running process
and remove the associated tokens from the cache.
AcquireTokenOnBehalfOfParameterBuilder InitiateLongRunningProcessInWebApi(IEnumerable<string> scopes, string userToken, ref string longRunningProcessSessionKey)
Parameters
scopes
IEnumerable<string>Scopes requested to access a protected API.
userToken
stringA JSON Web Token which was used to call this web API and contains the credential information about the user on behalf of whom to get a token.
longRunningProcessSessionKey
stringKey by which to look up the token in the cache. If null, it will be set to the assertion hash of the
userToken
by default.
Returns
- AcquireTokenOnBehalfOfParameterBuilder
A builder enabling you to add other parameters before executing the token request.
Remarks
This method should be called once when the long-running session is started.