How to implement JWT token with Shell script? how to sign jwt in shellscript?

getting error 401: invalid signature

Hey there @shanphode08 welcome to the community!

It’s hard to know what the issue could be given the information provided - Are you able to expand a bit on your use case here so we have a better idea of what you’re looking at?

The more details you can provide the better!

To brief on the requirement, environment set up dual mode of authentication, one is via API ID - API Key and second is JWT.

For JWT, they have specific requirement like below

  1. need to use ES256 Algorithm
  2. An Eliptical curve P-256 Key set to be used for JWK
  3. Expiry time should be 180s
  4. Data (in payload) to be hashed with SHA-256.

We are using shell script and openssl to achieve above requirement. We are converting Payload and Header into base64url encoding and generating a signature which is also encoded to base64url.

Using curl command we are trying to POST the above generated JWT along with API-ID and API Key to the target system

currenlty getting invalid signature error