Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Decode JWT TCL

Decode JWT TCL

Decode JWT TCL

I'm trying to find a way to decode a jwt using only the TCL, does anyone have it or know a way to do it?

JWT Exemple.

RE: Decode JWT TCL

There are several variants - with/without signaturea, with/without encryption. Does what you want to decode have encryption or signatures? If it is just a plain JWT, it could be possible but with signatures and/or encryption, it is quite unlikely that you can do anything with it unless you know the encryption keys and where the keys/signature lies in the token.

RE: Decode JWT TCL

Hey. Thanks for replying, they are. Simple jwts, no encryption or signature.

RE: Decode JWT TCL

I searched for JWT and found modules for Perl, Python, Ruby.
But for Tcl i found only this library: https://www.chilkatsoft.com/refdoc/tclJwtRef.html
I tried it, but could not figure out, how to decode your example with it.

In contrast, with Python I was done quickly:


>>> import jwt

>>> jwt_options = {
        'verify_signature': False,
        'verify_exp': False,
        'verify_nbf': False,
        'verify_iat': False,
        'verify_aud': False
>>> encoded_jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

>>> jwt.decode(encoded_jwt, key="", algorithms=['HS256', ], options=wt_options)
{'sub': '1234567890', 'name': 'John Doe', 'iat': 1516239022}

RE: Decode JWT TCL

Yeah, the challenge is to do it in tcl. I need to use this in a framework that only accepts tcl.dazed

RE: Decode JWT TCL

If you don't want to program the JWT decode algorithm yourself, then IMO you have these choices:
1) use the chilkat library (link given above), but it seems that it's not free and you have to buy it.
2) use any other external program (written in any other language) which should be called from Tcl and does the work. Then the result could be used inside of your Tcl code.
Personally, I would prefer the option 2

RE: Decode JWT TCL

Here are libraries in several programming languages available for JWT. Unfortunately Tcl is not in between.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close