internal virtual void DeleteFromCache(AccountSession accountSession) { if (accountSession != null) { var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this }; this.OnBeforeAccess(cacheNotificationArgs); this.OnBeforeWrite(cacheNotificationArgs); var credentialCacheKey = this.GetKeyForAuthResult(accountSession); this.cacheDictionary.Remove(credentialCacheKey); if (credentialCacheKey.Equals(this.MostRecentlyUsedKey)) { this.MostRecentlyUsedKey = null; } this.HasStateChanged = true; this.OnAfterAccess(cacheNotificationArgs); } }
internal override void AddToCache(AccountSession accountSession) { // Let ADAL handle the caching }
internal virtual async Task <AccountSession> ProcessCachedAccountSessionAsync(AccountSession accountSession, IHttpProvider httpProvider) { if (accountSession != null) { var shouldRefresh = accountSession.ShouldRefresh; // If we don't have an access token or it's expiring see if we can refresh the access token. if (shouldRefresh && accountSession.CanRefresh) { accountSession = await this.oAuthHelper.RedeemRefreshTokenAsync( accountSession.RefreshToken, this.clientId, this.clientSecret, this.returnUrl, this.scopes, httpProvider).ConfigureAwait(false); if (accountSession != null && !string.IsNullOrEmpty(accountSession.AccessToken)) { return(accountSession); } } else if (!shouldRefresh) { return(accountSession); } } return(null); }