squarealfa_security

Creator: coderz1093

Last updated:

0 purchases

squarealfa_security Image
squarealfa_security Images

Languages

Categories

Add to Cart

Description:

squarealfa security

SquareAlfa Security Package #
JWT #
The following example shows how to generate a JWT token.

var secret = '62zb8Sky_i_2kNAKFkORRa42XlQK09Bdtl_GHkTN';

// the JsonWebTokenHandler handles the generation and parsing of JWT tokens.
var tokenGenerator = JsonWebTokenHandler(secret);

// create the payload
var claims = JwtPayload(
name: 'John Doe',
email: '[email protected]',
subject: '5f35bd0489d72e2cd430f78d',
issuer: 'Our Server',
audience: 'Our Server',
notBefore: DateTime.now(),
expires: DateTime.now().add(Duration(seconds: 300)));

// finally, generate the JWT token.
var jwt = tokenGenerator.generate(claims);


copied to clipboard
The following code parses a JWT token:

var tokenGenerator = JsonWebTokenHandler(secret);
var jwt =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSm9obiBEb2UiLCJzdWIiOiI1ZjM1YmQwNDg5ZDcyZTJjZDQzMGY3OGQiLCJlbWFpbCI6InVzZXJAZG9tYWluLmNvbSIsImlzcyI6Ik91ciBTZXJ2ZXIiLCJhdWQiOiJPdXIgU2VydmVyIiwibmJmIjoiMTYwNTMyNjEyOCIsImV4cCI6IjE2MDUzMjY0MjgiLCJyb2xlcyI6bnVsbCwidWlkIjpudWxsLCJ0aWQiOm51bGx9.d9+mbsXtv5Xv2yAwaD1X4zOLM5aYa3edmQcYSSCP+II';
var payload = tokenGenerator.load(jwt);

copied to clipboard
Context #
This package is part of a set of losely integrated packages that constitute the Dartaculous Framework.

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.