Closed SpacyRicochet closed 7 years ago
Ah, I found it. Because encode(:,:)
uses a plain dictionary, it doesn't enforce any particular order for that library. What actually gets encoded is:
{"alg":"HS256","typ":"JWT"}
This results in the expected payload according to JWT.io. So, no errors here!
I'm currently trying to generate a simple JWT, where the only payload is a expiration date. However, my implementation when trying to use this library appears to generate a different token than when when I use https://github.com/yourkarma/JWT or when checking jwt.io (these two are consistent with each other).
Using the CocoaPods Playgrounds gem (
gem install cocoapods-playgrounds
), I tried out both of them, using equivalent implementations (as far as I can tell).JSONWebToken
Your Karma's JWT
jwt.io
Filling in the above settings in jwt.io, gives me the following key, which is equivalent to JWT's result;
(Take care with the order of
typ
andalg
in the website. By default, they appear to show it the other way around.)I'm thinking I'm filling in something wrong, but I can't spot it.
Any idea why the result for JSONWebToken is different?