kylef / JSONWebToken.swift

Swift implementation of JSON Web Token (JWT).
http://jwt.io
BSD 2-Clause "Simplified" License
763 stars 226 forks source link

"Issued at claim (iat) is in the future" error when using device, but not on the simulator. #34

Closed sweetcoco closed 8 years ago

sweetcoco commented 8 years ago

If I run my app in the Simulator I receive no errors and JSONWebToken decodes the server's JWT with no problem (node server is running on my localhost). However, when i run the app on my iPhone i get the error "Issued at claim (iat) is in the future". I've been troubleshooting for a couple hours now, I updated by CryptoSwift and JSONWebToken with no luck. Any ideas?

sweetcoco commented 8 years ago

Ignore this ticket. There is no need to decode on the front end and the server. just the server. Sorry!

kylef commented 8 years ago

I'd still like to get to the bottom of the problem so this doesn't affect others in the future. Are you able to supply me with an example JWT so I can debug this further?

Which iPhone model were you using?

kylef commented 8 years ago

I am wondering if it is just the iPhones date is set slightly behind the server and when you validate an issued token on the device you receive this validation error.

sweetcoco commented 8 years ago

The problem was this: I was creating the JWT on my localhost server, and then validating it on my iphone 6. my iphone's time was about 30seconds ahead of the server's time, so It was invaliding the jwt. I had to move my server time up a minute to get it working.

There is no reason to decode jwt's in an app though. at least as far as i can see, so simply dropping that fixed my issue.

aldocyanlabs commented 7 years ago

HI I've got the same "Issued at claim (iat) is in the future" error message when decoding. Is there any way to fix this without change server time? @kylef

StrawHatAaron commented 6 years ago

I could benefit from what @aldocyanlabs asked too since I don't have access some web features at my job. @kylef