Thalhammer / jwt-cpp

A header only library for creating and validating json web tokens in c++
https://thalhammer.github.io/jwt-cpp/
MIT License
828 stars 229 forks source link

How to use payload and get the payload data #338

Closed manishjha5410 closed 3 months ago

manishjha5410 commented 3 months ago

What's your question?

How to use payload and get the payload data in jwt

Additional Context

Hi @Thalhammer there is no documentation to use payload data please help if you can

prince-chrismc commented 3 months ago

You should not be using the Payload directly rather we provide a very customizable verifier https://thalhammer.github.io/jwt-cpp/classjwt_1_1verifier.html#a9ad51170089fb1566c5d97314cc33e41 you can see the various examples to validating claims.

If there is something specific you are trying to do please provide more information with a polite tone :)

manishjha5410 commented 3 months ago

So sorry for my tone i had a very bad day and unable to solve the issue from last week please apologies for the work thanks i am closing this issue

manishjha5410 commented 3 months ago

One last thing forgot to ask can i get the payload data from https://thalhammer.github.io/jwtcpp/classjwt_1_1payload.html#aabe0fc87ca6261eae5b7b32b7f2fd531 ?

prince-chrismc commented 3 months ago

https://thalhammer.github.io/jwt-cpp/classjwt_1_1decoded__jwt.html#a6a86e22661351e17f8880d6b4801ea9a

There's a few helpers on the decoded token :) you can get individual claims or the entire JSON object.

manishjha5410 commented 3 months ago

Hi buddy can you please tell me how to validate the signature of jwtToken you can see in this https://jwt.io/ the “signature verified” in your jwks verify example i just saw verifier.verify then nothing it is void function can you please help me

prince-chrismc commented 3 months ago

Please provide a reproducible examples with code and build scripts if applicable. A brief description of the workflow is also important.

Please refer to the various verify examples that are provided. Heres the one for RSA https://github.com/Thalhammer/jwt-cpp/blob/bd682eddba5b5fd56718a9cc13dfe2723b2986cd/example/rsa-verify.cpp#L28

prince-chrismc commented 3 months ago

Please open a new issue with more details as this is a different topic :)