jonasroussel / dart_jsonwebtoken

A dart implementation of the famous javascript library 'jsonwebtoken'
MIT License
87 stars 29 forks source link

Set expiresIn #8

Closed Tienisto closed 3 years ago

Tienisto commented 3 years ago

I cannot set the expiresIn (exp) attribute. Do I use the library correctly?

Here is my code piece:

String jwt = JWT({}).sign(
    SecretKey('somejwtsecretkeywhichijustmadeup'),
    algorithm: JWTAlgorithm.HS256,
    expiresIn: const Duration(days: 10)
);
jonasroussel commented 3 years ago

Yes, this is exactly how it should be used. Its a compilation error ? The generated jwt body's does not contains exp attribute ? I ran my example code with an expiresIn, and its work perfectly.

Tienisto commented 3 years ago

I think, that's because I used the {} argument. Using {'dummy': 'dummy'} works

jonasroussel commented 3 years ago

Ok ! I know why ! I will fix this soon.

jonasroussel commented 3 years ago

Fixed ! You can now use the v2.0.1