Closed fuelen closed 5 years ago
The 3rd argument to encode_and_sign/3
is a Keyword
list of options that can be used to override any defaults set in your configuration.
You might find the documentation for the Jwt
token module to be useful: https://github.com/ueberauth/guardian/blob/master/lib/guardian/token/jwt.ex
But using "typ" key I can override default value too
Since typ is also part of the jwt claims you can also use the claims to set the token type. As I understood it, both options are available because sometimes you have some claims and you want to sign a new token with those claims but a new token type. The options type makes this easy and you don't have to add typ to your already existing claims.
@fuelen is this still an issue for you?
We can set token type in 2 ways
and
but with 1st variant I can't pattern match by "sub" field in subject_for_token/2 function. It seems like I don't need token_type key in options at all.
Could anyone explain this design decision and how to use token types correctly?