Is there a way to set the iss claim of the JWT that is generated by create_access_token of Flask-JWT-Extended?
I tried to put the iss claim under the parameter 'user_claims' of the create_access_token:
access_token = create_access_token(
identity=data['username'],
expires_delta = timedelta(seconds=JWT_LIFE_SPAN),
user_claims={'iss': ISSUER}
)
However, when I decoded the token using PyJWT from the side of resource server, it looked like this:
{'iat': 1597581227, 'nbf': 1597581227, 'jti': '4e6c9677-d698-421c-91c4-0b2f3a6da4e9', 'exp':
1597583027, 'identity': 'asdf', 'fresh': False, 'type': 'access', 'user_claims': {'iss':
'sample-auth-server'}}
I tried to look for a configuration options from the docs, but I can't find any option to set the iss. There's an iss set, but it is under the user_claims. What I want to accomplish is to set it as one of the registered claims for the JWT.
I think you can make use of encode_access_token
api and create an encoded access code with issuer.
Example:
encode_access_token(
identity=data['username'],
issuer=JWT_ISSUER,
expires_delta=timedelta(seconds=JWT_LIFE_SPAN),
...
):