Token being generated based on Machine time, needs to be based on GMT time
reidsci opened this issue · 1 comments
It seems you are setting the expires time based on the local machine time and based on GMT time is what is expected.
Update to the following?
var requestAt = DateTime.UtcNow;
System.ArgumentException occurred
HResult=0x80070057
Message=IDX10401: Expires: '11/02/2017 20:12:57' must be after NotBefore: '11/03/2017 00:32:57'.
Source=
StackTrace:
at System.IdentityModel.Tokens.Jwt.JwtPayload..ctor(String issuer, String audience, IEnumerable1 claims, Nullable
1 notBefore, Nullable1 expires, Nullable
1 issuedAt)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.CreateJwtSecurityTokenPrivate(String issuer, String audience, ClaimsIdentity subject, Nullable1 notBefore, Nullable
1 expires, Nullable`1 issuedAt, SigningCredentials signingCredentials, EncryptingCredentials encryptingCredentials)
at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor)
at ASPNETCoreAngularJWT.TokenAuthController.GenerateToken(User user, DateTime expires) in D:\Users\Main\Visual Studio 2017\Projects\ASPNETcoreAngularJWT-master\Controllers\TokenAuthController.cs:line 64
at ASPNETCoreAngularJWT.TokenAuthController.Login(User user) in D:\Users\Main\Visual Studio 2017\Projects\ASPNETcoreAngularJWT-master\Controllers\TokenAuthController.cs:line 31
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()
This is only for learning purpose, not for production