Last active
November 6, 2018 23:54
-
-
Save evgomes/474a729890a42504a8502c5c0337b40c to your computer and use it in GitHub Desktop.
Build access token method from the token handler of JWT API.
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
private AccessToken BuildAccessToken(User user, RefreshToken refreshToken) | |
{ | |
var accessTokenExpiration = DateTime.UtcNow.AddSeconds(_tokenOptions.AccessTokenExpiration); | |
var securityToken = new JwtSecurityToken | |
( | |
issuer : _tokenOptions.Issuer, | |
audience : _tokenOptions.Audience, | |
claims : GetClaims(user), | |
expires : accessTokenExpiration, | |
notBefore : DateTime.UtcNow, | |
signingCredentials : _signingConfigurations.SigningCredentials | |
); | |
var handler = new JwtSecurityTokenHandler(); | |
var accessToken = handler.WriteToken(securityToken); | |
return new AccessToken(accessToken, accessTokenExpiration.Ticks, refreshToken); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment