A JWT token generator package for flutter and dart.

Features

Generate HS256 algorithm jwt token.

Getting started

Add the depency to pubspec.yaml and start using its methods.

Usage

  1. Instantiate JWT class.
  2. Declare the payload.
  3. Use generateToken method.
JWT jwt = JWT();
Map<String, dynamic> payload = {
    'iss': 'localhost',
    'exp': DateTime.now().add(Duration(hours: 1)).millisecondsSinceEpoch / 1000,
    'id': 1,
    'fullname': 'User name'
};
String token = await jwt.generateToken(payload: payload, secretKey: 'SampleKey');

To validate JWT

  1. Instantiate JWT class.
  2. Use validate JWT method.
JWT jwt = JWT();
bool isValidated = await jwt.verifyTokey(token: token, secretKey: secretKey);
print(isValidated);// True or False

Additional information

Currently supported algorithm: HS256 will be adding more algorithm soon or if you want to contribute you are welcome.

Libraries

jwt_token_generator
Support for doing something awesome.