public async Task <IEnumerable <GrantedToken> > GetTokens(IEnumerable <string> tokenIds) { if (tokenIds == null) { throw new ArgumentNullException(nameof(tokenIds)); } var tasks = new List <Task <GrantedToken> >(); foreach (var tokenId in tokenIds) { tasks.Add(_storage.TryGetValueAsync <GrantedToken>(tokenId)); } var result = await Task.WhenAll(tasks); return(result.Where(r => r != null)); }
public async Task <bool> AddAuthorizationCode(AuthorizationCode authorizationCode) { if (authorizationCode == null) { throw new ArgumentNullException(nameof(authorizationCode)); } var authCode = await _storage.TryGetValueAsync <AuthorizationCode>(authorizationCode.Code); if (authCode != null) { return(false); } // TH : Externalize the date. await _storage.SetAsync(authorizationCode.Code, authorizationCode, 3600); return(true); }