Jonas Roussel 3377ae8b0b v0.2.1
2020-05-31 18:38:13 +02:00
2020-05-31 18:38:13 +02:00
2020-05-31 18:38:13 +02:00
2020-05-30 01:14:08 +02:00
2020-05-31 18:38:13 +02:00
2020-05-31 16:12:10 +02:00
2020-05-31 18:38:13 +02:00
2020-05-31 18:38:13 +02:00

JsonWebToken

pub package

A dart implementation of the famous javascript library 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
}
Description
An easy to use JSON Web Token implementation in Dart (all algorithms supported).
Readme MIT 310 KiB
Languages
Dart 100%