Microsoft.WindowsAzure.Commands.Utilities.Common.Authentication.AdalTokenProvider.GetCachedToken C# (CSharp) Method

GetCachedToken() public method

public GetCachedToken ( WindowsAzureSubscription subscription, string userId ) : IAccessToken
subscription WindowsAzureSubscription
userId string
return IAccessToken
        public IAccessToken GetCachedToken(WindowsAzureSubscription subscription, string userId)
        {
            var key = tokenCache.Keys.FirstOrDefault(k => k.UserId == userId && k.TenantId == subscription.ActiveDirectoryTenantId);
            if (key == null)
            {
                throw new AadAuthenticationFailedException(string.Format(Resources.NoCachedToken,
                    subscription.SubscriptionName, userId));
            }

            return new AdalAccessToken(DecodeCachedAuthResult(key), this, new AdalConfiguration(subscription));
        }