dart_jwt_token

Creator: coderz1093

Last updated:

0 purchases

dart_jwt_token Image
dart_jwt_token Images

Languages

Categories

Add to Cart

Description:

dart jwt token

Dart JWT package lets you create jwt token.
Installation #

Add this to your package's pubspec.yaml file:

dependencies:
dart_jwt_token: ^0.0.2
copied to clipboard

You can install packages from the command line with Flutter:

$ dart pub get
copied to clipboard

Import the package and use it in your Flutter App.

import 'package:dart_jwt_token/dart_jwt_token.dart';
copied to clipboard
Usage #
Create JWT Token #
String createToken(
{required Map payload,
required Map<String, dynamic> headers,
required SecretKey key}) {
String token = "";
final jwt = JWT(payload, header: headers);
token = jwt.sign(key);
return token;
}
copied to clipboard
Verify JWT Token #
Map<String, dynamic> verifyToken(String token, SecretKey key) {
try {
final jwt = JWT.verify(token, key);
return jwt.payload;
} on JWTExpiredError {
return {"expired": true};
} on JWTError catch (ex) {
return {"Error": ex.message};
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.