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

outdated

This small library helps you to decode Json Web Tokens, you can also know if a JWT is already expired.

example/example.dart

import 'package:jwt_decoder/jwt_decoder.dart';

main() {
  String token =
      "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikd1c3Rhdm8iLCJpYXQiOjE1MTYyMzkwMjIsImV4cCI6NDczNDYxNTg1OH0.hh-TTBPS8z-UxdmfXWn7AwW2y_Lq3aPnlIQdqV2KEC4";

  // decode() method will decode your token's payload
  Map<String, dynamic> decodedToken = JwtDecoder.decode(token);
  // Now you can use your decoded token
  print(decodedToken["name"]);

  // isExpired() method will tell you if your token is already expired or not.
  // An useful method when you have to handle sessions and you want the user
  // to authenticate if has an expired token
  bool isTokenExpired = JwtDecoder.isExpired(token);

  if (!isTokenExpired) {
    // The user should authenticate
  }
}
488
likes
0
pub points
99%
popularity

Publisher

unverified uploader

This small library helps you to decode Json Web Tokens, you can also know if a JWT is already expired.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on jwt_decoder