Bearer error="invalid_token", error_description="The token is not valid before '11/14/2026 01:23:01'"
means the token's nbf (not before) time is still in the future by the API's
clock. Issue tokens with nbf set to the current UTC time, and compare the
token's nbf with the API's UTC time.
The time in the message is UTC. Compare it with the response's Date header,
which is also UTC: the gap between them is how far ahead the token is.
The error
The response, from curl.exe -i, for a token whose nbf was set ten minutes ahead:
$token = .\mint\bin\Debug\net10.0\Mint.exe "fix11-test-only-signing-key-0123456789abcdef" https://issuer.test fix11-api 30 10
curl.exe -i http://127.0.0.1:15600/patients -H "Authorization: Bearer $token"
HTTP/1.1 401 Unauthorized
Content-Length: 0
Date: Sat, 14 Nov 2026 01:13:01 GMT
Server: Kestrel
WWW-Authenticate: Bearer error="invalid_token", error_description="The token is not valid before '11/14/2026 01:23:01'"
The server console:
info: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[1]
Failed to validate the token.
Microsoft.IdentityModel.Tokens.SecurityTokenNotYetValidException: IDX10222: Lifetime validation failed. The token is not yet valid. ValidFrom (UTC): '14-11-2026 01:23:01', Current time (UTC): '14-11-2026 01:13:02'.
...
Why it happens
The test's token maker takes the not-before offset in minutes as its last argument, and
10 put nbf at 01:23:01 UTC while the server's clock said 01:13:02.
Lifetime validation refuses a token before its nbf time, and the log names the
failure IDX10222 with both times.
In an application, the same message points at the token issuer: it wrote an nbf later
than the API's clock. A clock difference between the two machines is one possible reason
that this test did not reproduce. Ten minutes was enough to be
refused with the default settings; smaller gaps were not tested here.
The fix
The token maker's code, from the test's Program.cs, with nbf taken from the current UTC time:
var now = DateTime.UtcNow;
...
notBefore: now.AddMinutes(notBefore),
expires: now.AddMinutes(expires),
signingCredentials: credentials);
The same request with an offset of zero:
$token = .\mint\bin\Debug\net10.0\Mint.exe "fix11-test-only-signing-key-0123456789abcdef" https://issuer.test fix11-api 30 0
curl.exe -i http://127.0.0.1:15600/patients -H "Authorization: Bearer $token"
HTTP/1.1 200 OK
...
["Maria Garcia","David Chen"]
Fill token times from DateTime.UtcNow, as the token maker above does, and keep
the clocks of the issuing and the validating machine synchronised. The token then carries a
start time the API has already reached.
How it was reproduced
A dotnet new web -f net10.0 API with Microsoft.AspNetCore.Authentication.JwtBearer
10.0.15 (Microsoft.IdentityModel 8.19.2) and one endpoint protected with
RequireAuthorization(), on 127.0.0.1:15600 with the ASP.NET Core 10.0.15 runtime
and SDK 11.0.100, the Microsoft.AspNetCore.Authentication log category at
Information. A console project on System.IdentityModel.Tokens.Jwt 8.19.2 made HS256 tokens
with expiry and not-before given in minutes from now; the key is a made-up test string.
Requests went through curl 8.22.0 on Windows.
Frequently asked
- What does IDX10222 The token is not yet valid mean?
- The token's nbf claim is later than the API's current UTC time. In the test a token with nbf ten minutes ahead was refused with a 401 and this line in the server log.
- Is the time in 'The token is not valid before' UTC?
- Yes. The log labels it ValidFrom (UTC), and in the test it was ten minutes after the UTC time in the response Date header.
- How do I fix a JWT that is not valid yet?
- Set nbf from DateTime.UtcNow when the token is created and keep the issuer's and the API's clocks in sync. In the test a token with nbf set to now got a 200.
More decoded errors in the Fixes category. The other end of the lifetime check is The token expired at (IDX10223), with the clock skew tested.