The token is not yet valid (iat).
See original GitHub issueWe found an issue in one of our tests in the recent update of yours. Our package works with pyjwt==2.5.0
but it breaks with pyjwt==2.6.0
. We will give more details on the issue once we explore it more and will try to provide a minimal example that reproduces the error. However, may I ask you to check if the latests changes could have broken backawards compatibility? We are particularly suspicious of #794. We think this because the error message we get: The token is not yet valid (iat)
.
We are sorry we could not provide more details yet.
System Information
$ python -m jwt.help
{
"cryptography": {
"version": "38.0.1"
},
"implementation": {
"name": "CPython",
"version": "3.10.6"
},
"platform": {
"release": "5.19.16-76051916-generic",
"system": "Linux"
},
"pyjwt": {
"version": "2.6.0"
}
}
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
JWT token not yet valid - Stack Overflow
The id-token is set in each request header I send to my custom api. I'm currently getting 2 issues with the code below:...
Read more >AccessToken is not (yet) valid - Auth0 Community
The iat claim is the 'issued at'. So you are saying it is issued at 8:52:45, and is being validated at 8:52:44 (which...
Read more >Solved: "IgnoreIssuedAt" on VerifyJWT policy usage
Solved: Hello, I'm trying to execute a validation on 2 sequencial tokens with ... VerifyJWT policy on Apigee can reject the inbound JWT...
Read more >How to get an access token with JWT Grant
One of the most common ways to encounter this error is for the iat and exp timestamp values in the JWT body to...
Read more >Troubleshooting Invalid Access Tokens - Twilio Support
Token is not yet valid or already expired. Ensure your server clock hasn't drifted and verify the validity period of the token. For...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve also encountered this issue, particularly in tests where the token is issued within a few milliseconds of when it gets used. The problem is that the
iat
is assumed to be an integer, while the RFC allows floats. If a token is issued with a floatiat
and decoded within that second, the code will test against the integer second, which is less than the floatiat
. This results inImmatureSignatureError
being raised.Here is an example that used to succeed, but now raises an error:
I suggest either allowing full float calculations or casting the input
iat
to an int.It’s yes and no, since most JWT libraries in other languages also support the
int
type this could cause an issue. I agree with the fact that float has a bit more precision than int but to tackle this synchronization issue the recommended way isleeway time
. So adding the minimum leeway time will help them without changing the custom logic they have now.An example could be,
jwt.decode(jwt.encode({'iat': int(time.time())+leeway}, 'secret', algorithm='HS256'), 'secret', algorithms=['HS256'])
With this,
PyJWT
will be in sync with other frameworks/libraries in other languages as well.