Reputation: 172
I am given a JWT which does not contain any dots. I read somewhere that the typical format of a JWT is 3 pieces of string concatenated with 2 dots in total. Using PyJWT when I try to decode the token, I am getting the below error -
Traceback (most recent call last):
File "/home/neelanjana/.virtualenvs/athena_env/lib/python3.7/site-packages/jwt/api_jws.py", line 180, in _load
signing_input, crypto_segment = jwt.rsplit(b'.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/neelanjana/.virtualenvs/athena_env/lib/python3.7/site-packages/jwt/api_jwt.py", line 84, in decode
payload, _, _, _ = self._load(jwt)
File "/home/neelanjana/.virtualenvs/athena_env/lib/python3.7/site-packages/jwt/api_jws.py", line 183, in _load
raise DecodeError('Not enough segments')
jwt.exceptions.DecodeError: Not enough segments
However, when I put the same token on jwt.io, it gets decoded and I am able to see the complete dictionary. Is What am I missing?
Here is my code -
import jwt
a = "someToken"
print(jwt.decode(a))
Attaching a pastebin link to the token here since it is too long to put here.
P.S. I am not married to the idea of using pyjwt. If any other library can decode it it's all the same for me.
Upvotes: 1
Views: 3623
Reputation: 172
To answer my own question, the above string is not JWT but a base64 encoded string. Using base64 decoding the actual dict was recovered.
Upvotes: 0