• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » What is JSON Web Token (JWT)?

By Abhishek Ghosh December 16, 2023 7:17 am Updated on December 16, 2023

What is JSON Web Token (JWT)?

Advertisement

A JSON Web Token (JWT) is a JSON-based access token standardized according to RFC. The JWT enables the exchange of verifiable claims. It is typically used to exchange a user’s identity between an identity provider and a service provider in a third-party system. JWTs are particularly suitable for implementing “stateless sessions”, as all authentication-relevant information can be transmitted in the token and the session does not have to be stored additionally on a server.

Advantage of JWT is that it is stateless. No data needs to be persistent to authenticate any user. Also, we do not need any other source to verify the user.

 

Construction of a JSON Web Token (JWT)

 

A JWT consists of three parts: the header, payload, and signature.

Advertisement

---

Header

The header is a JSON element that describes what type of token it is and which signature method is used.

  • typ : Type describes the IANA media type of the token. This value is always used to describe the media type. JWTapplication/jwt
  • cty : Content Type field is required if the JWT contains another JWT as a payload. In this case, it is set to . Otherwise, this field should be omitted.
  • alg: Algorithm Describes which signature method is used. The signature method is usually HMAC with SHA-256 or RSA with SHA-256. It is possible not to use a signature, but this is not recommended. The possible values are standardized by JSON Web Encryption (JWE) according to RFC 7516.

The typ and alg are object keys with different values and give us the type of the header of this information packet and the encryption algorithm used.

Example of header:

Vim
1
2
3
4
{
    "typ":"JWT",
    "alg":"HS256"
}

The payload is then Base64Url encoded to form the first part of the JSON Web Token.

What is JSON Web Token JWT
Payload

The payload is a JSON element that describes the claims.

  • iss : The issuer of the token
  • sub : Defines the subject to which the claims apply. The field defines for whom or what the claims are made. sub
  • aud : The destination domain (audience) for which the token was issued.
  • exp : The expiration date of the token in Unix time
  • nbf : The Unix time from which the token is valid.
  • iat : The Unix time at which the token was issued.
  • jti : A unique case-sensitive string that uniquely identifies the token. This can be used to prevent the token from being replicated. This can be a counted number, a GUID or a hash value. If the token recipient receives a token from multiple issuers, the JWT ID may not be unique. By combining the issuer (iss) and the JWT ID (jti), this can become unique again.

Furthermore, public claims are defined by the IANA. In addition, the issuer of the JWT can also use a private claim-defined URI, which is not standardized. For example, an ontology such as Dublin Core or FOAF can be used here.

Example:

Vim
1
2
3
4
5
6
{
     "userId":"n09t85ae-69da",
     "iss": "https://thecustomizewindows.com/",
     "sub": "auth/hash-code",
     "exp": 153452683
}

The payload is then Base64Url encoded to form the second part of the JSON Web Token.

Signature

Securely validates the token. The structure of the signature is defined by JSON Web Signature (JWS), a standard standardized according to RFC 7515. The signature is generated by hashing the header and payload in Base64 encoded format with the specified hash method.

For example, if we want to use the HMAC SHA256 algorithm, the signature will be created in the following way:

Vim
1
2
3
4
HMACSHA256(
  base64UrlEncode(header) + "." +
  base64UrlEncode(payload),
  secret)

The Total Thing

The header, payload and signature are each encoded with a Base64 URL and separated by a period. A JWT token can look like this:

Vim
1
var jwt = base64UrlEncode(header) + "." + base64UrlEncode(payload) + "." + base64UrlEncode(hash)

The output will look like this:

Vim
1
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjEzMDA4MTkzODAsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773

You’ll get debugger, parser, libraries here: jwt.io/#debugger-io
You’ll get ready to implement projects on GitHub in most of the common languages, such as C++, Java, PHP, Python and so on. For exapmle:

Vim
1
https://github.com/kelvinmo/simplejwt

The JWT can be transmitted in the URL or in the HTTP header.

Vim
1
http://example.com/path?jwt_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…

There are two ways to transfer in the HTTP header: the authorization field or the cookie field.

in the Authorization field as a bearer token:

Vim
1
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…

in the cookie field:

Vim
1
Cookie: token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…

It works with CORS, but requires implementation in JavaScript.

A Security Event Token (SET) extends the JWT standard with the claim, which records a list of security-relevant events. These tokens have a digital timestamp and unlimited validity. A SET payload can look like this:

Vim
1
2
3
4
5
6
7
8
9
10
11
{
  "iss": "https://server.example.com",
  "sub": "248289761001",
  "aud": "s6BhdRkqt3",
  "iat": 1471566154,
  "jti": "bWJq",
  "sid": "08a5019c-17e1-4977-8f42-65a12843ea02",
  "events": {
    "http://schemas.openid.net/event/backchannel-logout": {}
  }
}

 

Conclusion

 

JWT is a great solution, but it works best in certain scenarios. JWT is best suited when communicating API to API and may be in IoT. It is risky to use JWT for web-based login procedures (requires a lot of steps to mitigate the probable weak points).

Tagged With JSON веб-токены
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to What is JSON Web Token (JWT)?

  • JSON-LD in Details

    JSON-LD (JSON for Linked data) refers to the recommendation of the W3C, embedded linked data in the lightweight JSON Format. Here is details.

  • WROOM ESP32 Example Codes For IBM Watson IoT Platform

    Here Are Few WROOM ESP32 Example Codes For IBM Watson IoT Platform So That Anyone Can Get Started With Both of Them Without Huge Experience.

  • Connecting ESP32 Arduino with DHT11 with IBM Watson IoT

    Earlier, we described how to create graph on IBM Watson IoT dashboard by using the default widgets. In previous guide, we described how to use ESP32 Arduino with DHT11 sensor. Here is the Code and Diagram to Connect ESP32 Arduino with DHT11 with IBM Watson IoT and Get Odometer Like Gauges on Dashboard. For this […]

  • Token Ring Local Area Network (LAN) Technology

    Token Ring Local Area Network (LAN) Technology is a networking technology for computer networks, it is defined in the specification as IEEE 802.5. It defines the cable types and signaling for the physical layer, packet formats and protocols for the media access control (MAC) or data link layer of the OSI model. It is one […]

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy