public async Task <ValidationResult> GetTokenForValidHostAsync(string applicationName, string host, Guid identityId, Guid correlationId, bool rememberMe) { if (string.IsNullOrEmpty(host)) { return(ValidationResult.Failure()); } var externalApplication = await _externalApplicationStorage.GetFromApplicationNameAndHostAsync(applicationName, host); if (externalApplication == default(ExternalApplication)) { return(ValidationResult.Failure()); } var bytes = new byte[32]; CryptoRandom.GetBytes(bytes); var tokenId = Base64UrlTextEncoder.Encode(bytes); var token = new Token { TokenId = tokenId, Created = DateTimeOffset.Now, ExternalApplicationId = externalApplication.ExternalApplicationId, IdentityId = identityId, Expiration = rememberMe, CorrelationId = correlationId }; await _tokenStorage.CreateAsync(token); return(ValidationResult.Success(token.TokenId)); }