DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Runtime Formula Evaluation With MVEL Library in Spring Boot
  • C/C++ Is Where Vulnerability Programs Go to Guess
  • Building a Java 17-Compatible TLD Generator for Legacy JSP Tag Libraries
  • Extracting Clean Excel Tables From PDFs Using Python + Docling

Trending

  • Engineering Closed-Loop Graph-RAG Systems, Part 3: Closing the Loop in Graph-RAG Systems
  • How to Implement AI Agents in Rails With RubyLLM
  • Architecting Zero-Trust AI Agents: How to Handle Data Safely
  • The Developer's Guide to Context-Aware AI: When Your Code Documentation Becomes Intelligent
  1. DZone
  2. Coding
  3. Languages
  4. jwt-cli: A Shell Library to Decode JWTs [Snippet]

jwt-cli: A Shell Library to Decode JWTs [Snippet]

Check out this handy shell script that makes it easy to decode multiple JSON Web Tokens, as well as a code snippet of the script in action.

By 
Enrico Maria Crisostomo user avatar
Enrico Maria Crisostomo
·
May. 15, 18 · Code Snippet
Likes (1)
Comment
Save
Tweet
Share
10.8K Views

Join the DZone community and get the full member experience.

Join For Free

When I started needing to decode JSON Web Tokens quite often, I felt the urge to write a program that allowed me to do it quickly. There are excellent options, such as jwt.io, but as soon as you need to do this operation often enough, it becomes clumsy. And if you need to process multiple tokens, or further process the output, something else becomes a necessity.

That's why I wrote a little shell script that allows you to do just that. jwt-decode will accept a list of tokens as arguments and will decode them on a standard output. The syntax is the following:

$ jwt-decode token ...
{
  "alg": "RS256",
  "typ": "JWT",
  "kid": "sbS_BWBm0GzfIQRnYWolcWDRnjqwDTY_Aq6Fn_boqKM"
}
{
  "jti": "271151a3-db11-4f37-a724-4cf9957774f4",
  "exp": 1530979706,
  "nbf": 0,
  "iat": 1523117306,
  "iss": "https://domain.com/auth/realms/realm",
  "aud": "app-name",
  "sub": "5132c417-d772-420e-b5db-401ea633dca1",
  "typ": "Bearer",
  "azp": "app",
  "auth_time": 0,
  "session_state": "84e6a759-e54d-4fd7-9fcf-bb51131aab89",
  "acr": "1",
  "allowed-origins": [
    ""
  ],
  "realm_access": {
    "roles": [
      "role0",
      "role1",
      "role2"
    ]
  },
  "resource_access": {
    "account": {
      "roles": [
        "manage-account",
        "manage-account-links",
        "view-profile"
      ]
    }
  },
  "custom-property": "1797"
}
...


You can find jwt-cli on GitHub.

shell Library

Published at DZone with permission of Enrico Maria Crisostomo. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Runtime Formula Evaluation With MVEL Library in Spring Boot
  • C/C++ Is Where Vulnerability Programs Go to Guess
  • Building a Java 17-Compatible TLD Generator for Legacy JSP Tag Libraries
  • Extracting Clean Excel Tables From PDFs Using Python + Docling

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook