jwt_io 1.1.3 copy "jwt_io: ^1.1.3" to clipboard
jwt_io: ^1.1.3 copied to clipboard

outdated

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

example/example.dart

import 'package:jwt_io/jwt_io.dart';

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

  /* decode() method will decode your token's payload */
  final decodedToken = JwtToken.payload(token);
  // Now you can use your decoded token
  print(decodedToken["name"]);

  /* isExpired() - you can use this method to know 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 */
  final isTokenExpired = JwtToken.isExpired(token);

  if (!isTokenExpired) {
    // The user should authenticate
  }

  /* getExpirationDate() - this method returns the expiration date of the token */
  final expirationDate = JwtToken.getExpirationDate(token);

  // 2025-01-13 13:04:18.000
  print(expirationDate);

  /* getTokenTime() - You can use this method to know how old your token is */
  final tokenTime = JwtToken.getTokenTime(token);

  // 15
  print(tokenTime.inDays);
}
20
likes
0
pub points
83%
popularity

Publisher

verified publisherglynskyi.com

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on jwt_io