Last active
January 10, 2017 19:24
-
-
Save aevitas/ac977598cf51fbf83e5b9a3f9bd294f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public JwtSecurityToken Generate(string userId, IEnumerable<Claim> claims) | |
{ | |
Requires.NotEmpty(userId, nameof(userId)); | |
// We're using a DateTimeOffset and later using the DateTime property thereof so we don't | |
// have to mess with extension methods to grab UNIX time, as DateTimeOffset has those built in. | |
var timeStamp = DateTimeOffset.UtcNow; | |
var token = new JwtSecurityToken(_options.Issuer, _options.Audience, claims, timeStamp.DateTime, | |
timeStamp.Add(_options.Expiration).DateTime, _options.SigningCredentials); | |
return token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment