Flutter: How to decode JWT token using Dart?
JWT tokens are 3 Base64 strings separated by “.”.
- Part 1 is called Header. it contains an algorithm and token type.
- Part 2 is called Payload. it contains user data.
- Part 3 is called Signature. Which is calculated like following:
<Hashing Algo: e.g. HMACSHA256 etc>(
base64UrlEncode(header) + "." + base64UrlEncode(payload), "secret string<Known to JWT creator>"
As a Application developer we are mostly interested in decoding the Payload to get User…