C# Class Tailspin.Surveys.Web.Security.SurveysTokenService

This service helps with the acquisition of access tokens from Azure Active Directory.
Inheritance: ISurveysTokenService
Show file Open project: Azure-Samples/guidance-identity-management-for-multitenant-apps

Public Methods

Method Description
ClearCacheAsync ( ClaimsPrincipal claimsPrincipal ) : System.Threading.Tasks.Task

This method clears the user's Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache.

GetTokenForWebApiAsync ( ClaimsPrincipal user ) : Task

This method retrieves the access token for the WebAPI resource that has previously been retrieved and cached. This method will fail if an access token for the WebAPI resource has not been retrieved and cached. You can use the RequestAccessTokenAsync method to retrieve and cache access tokens.

RequestTokenAsync ( ClaimsPrincipal claimsPrincipal, string authorizationCode, string redirectUri, string resource ) : Task

This method acquires an access token using an authorization code and ADAL. The access token is then cached in a TokenCache to be used later (by calls to GetTokenForWebApiAsync).

SurveysTokenService ( IOptions options, ITokenCacheService tokenCacheService, ICredentialService credentialService, ILogger logger ) : System

Initializes a new instance of Tailspin.Surveys.Web.Security.SurveysTokenService.

Private Methods

Method Description
CreateAuthenticationContext ( ClaimsPrincipal claimsPrincipal ) : Task
GetAccessTokenForResourceAsync ( string resource, ClaimsPrincipal user ) : Task

Method Details

ClearCacheAsync() public method

This method clears the user's Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache.
public ClearCacheAsync ( ClaimsPrincipal claimsPrincipal ) : System.Threading.Tasks.Task
claimsPrincipal System.Security.Claims.ClaimsPrincipal The for the user
return System.Threading.Tasks.Task

GetTokenForWebApiAsync() public method

This method retrieves the access token for the WebAPI resource that has previously been retrieved and cached. This method will fail if an access token for the WebAPI resource has not been retrieved and cached. You can use the RequestAccessTokenAsync method to retrieve and cache access tokens.
public GetTokenForWebApiAsync ( ClaimsPrincipal user ) : Task
user System.Security.Claims.ClaimsPrincipal The for the user to whom the access token belongs.
return Task

RequestTokenAsync() public method

This method acquires an access token using an authorization code and ADAL. The access token is then cached in a TokenCache to be used later (by calls to GetTokenForWebApiAsync).
public RequestTokenAsync ( ClaimsPrincipal claimsPrincipal, string authorizationCode, string redirectUri, string resource ) : Task
claimsPrincipal System.Security.Claims.ClaimsPrincipal A for the signed in user
authorizationCode string a string authorization code obtained when the user signed in
redirectUri string The Uri of the application requesting the access token
resource string The resouce identifier of the target resource
return Task

SurveysTokenService() public method

Initializes a new instance of Tailspin.Surveys.Web.Security.SurveysTokenService.
public SurveysTokenService ( IOptions options, ITokenCacheService tokenCacheService, ICredentialService credentialService, ILogger logger ) : System
options IOptions
tokenCacheService ITokenCacheService
credentialService ICredentialService
logger ILogger
return System