dart_jsonwebtoken 0.2.0 copy "dart_jsonwebtoken: ^0.2.0" to clipboard
dart_jsonwebtoken: ^0.2.0 copied to clipboard

outdated

A dart implementation of the famous javascript library 'jsonwebtoken' (https://www.npmjs.com/package/jsonwebtoken).

JsonWebToken #

pub package

A dart implementation of the famous javascript library 'jsonwebtoken' (https://www.npmjs.com/package/jsonwebtoken).

Usage #

Import #

import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';

Sign #

// Create a json web token
final jwt = JWT(
  payload: {
    'id': 123,
    'server': {
      'id': '3e4fc296',
      'loc': 'euw-2',
    }
  },
  issuer: 'https://github.com/jonasroussel/jsonwebtoken',
);

// Sign it
token = jwt.sign('secret-key');

print('Signed token: $token\n');

Verify #

try {
  // Verify a token
  final jwt = JWT.verify(token, 'secret-key');

  print('Payload: ${jwt.payload}');
} on JWTExpiredError {
  print('jwt expired');
} on JWTError catch (ex) {
  print(ex.message); // ex: invalid signature
}
282
likes
0
pub points
99%
popularity

Publisher

verified publisherjonasroussel.com

A dart implementation of the famous javascript library 'jsonwebtoken' (https://www.npmjs.com/package/jsonwebtoken).

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto

More

Packages that depend on dart_jsonwebtoken