Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize the Header field #368

Open
jiashiwen opened this issue Jan 23, 2024 · 4 comments
Open

How to customize the Header field #368

jiashiwen opened this issue Jan 23, 2024 · 4 comments

Comments

@jiashiwen
Copy link

Some of my python or java programs found the following definitions

python

  return jwt.encode(
    payload,
    secret,
    algorithm="HS256",
    headers={"alg": "HS256", "sign_type": "SIGN"},
)

java

 headerClaims.put("alg", "HS256");
 headerClaims.put("sign_type", "SIGN");
 String token = JWT.create().withPayload(payload).withHeader(headerClaims).sign(alg);

However, the "sign_type" field is not seen in the jsonwebtoken::Header definition. How to customize the header's custom fields?

@Keats
Copy link
Owner

Keats commented Jan 23, 2024

You can't, you can only use header fields from the spec in this library

@jiashiwen
Copy link
Author

A hashmap may be needed to provide the function of custom fields, and some access may require

@kitty-eu-org
Copy link

+1

@yspreen
Copy link

yspreen commented Aug 23, 2024

very unfortunate, makes the library unusable for cases like https://developer.apple.com/documentation/weatherkitrestapi/request_authentication_for_weatherkit_rest_api

which needs an id field in the header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants