jwt_decoder 1.0.0 copy "jwt_decoder: ^1.0.0" to clipboard
jwt_decoder: ^1.0.0 copied to clipboard

outdated

Json Web Tokens decoder.

JWT Decoder #

This is a small library for decoding a json web token for dart / flutter. Since the header and payload is base64 encoded you can easily know the stored data with no password, you can also know if the token is expired or not.

If you like this library there's a version for Vue here.

Getting Started #

Decode a token

main() {
  String yourToken = "Your JWT";
  Map<String, dynamic> decodedToken = JwtDecoder.decode(yourToken);
  
  // If the token has a valid format, you will get a Map<String, dynamic>
  // Your decoded token can look like:
  // { 
  //    "sub": "1234567890", 
  //    "name": "Gustavo", 
  //    "iat": 1516239022, 
  //    "exp": 1516239022, 
  //    "randomKey": "something else" 
  // }
}

Know if the token is expired

main() {
  String yourToken = "Your JWT";
  bool hasExpired = JwtDecoder.isExpired(yourToken);
  
  // You will get a true / false response
  // true: if the token is already expired
  // false: if the token is not expired
}
488
likes
0
pub points
99%
popularity

Publisher

unverified uploader

Json Web Tokens decoder.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on jwt_decoder