jaguar_jwt 0.1.1 jaguar_jwt: ^0.1.1 copied to clipboard
JWT interceptor and utilities for Jaguar
library jaguar_jwt.example;
import 'package:dart_jwt/dart_jwt.dart';
import 'package:jaguar_jwt/jaguar_jwt.dart';
void main() {
//Issuing a JWT token
final encoder = new JwtAuthenticationContext(
new JwaSymmetricKeySignatureContext('dfsdffasdfdgdfgdfg456456456'),
'teja',
audience: <String>['admin', 'students']);
JaguarJwtClaimSet claimSet = new JaguarJwtClaimSet(
'kleak', encoder.issuer, encoder.audience, {'k': 'v'});
String encoded = encoder.encodeClaimSet(claimSet);
print(encoded);
//Decoding a token
final decoder = new JwtAuthorizationContext(
new JwaSymmetricKeySignatureContext('dfsdffasdfdgdfgdfg456456456'),
'teja',
audience: <String>['students']);
JsonWebToken decoded = decoder.decodeToken(encoded);
print(decoded.claimSet.toJson());
}