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

Api referece - documentation #41

Closed
nicraMarcin opened this issue Sep 17, 2019 · 7 comments · Fixed by #76
Closed

Api referece - documentation #41

nicraMarcin opened this issue Sep 17, 2019 · 7 comments · Fixed by #76

Comments

@nicraMarcin
Copy link

Where can I find some api referece and some examples? for example: how to use with rsa public and private key

@Thalhammer
Copy link
Owner

Currently the only documentation are the example in README.md and the various testcases in *Test.cpp

@nicraMarcin
Copy link
Author

:(

@Thalhammer
Copy link
Owner

I almost forgot about it, but most of the methods are commented with doxygen comments and there is a doxygen config in the root. It's not really a complete documentation, but it might help.

@paulotovo
Copy link

Hello Thalhammer,

I have seen on several sites about the header "typ" parameter that must be configured as JWT.
For example: "typ" : "JWT"
But on RFC says:
"The "typ" (type) Header Parameter defined by [JWS] and [JWE] is used
by JWT applications" and " If present, it is RECOMMENDED that
its value be "JWT" to indicate that this object is a JWT."

In your examples you use "typ" : "JWS".

What would be the difference? What would be the correct use?

Thanks.

Best Regards

Paulo

@Thalhammer
Copy link
Owner

@paulotovo According to the rfc that part is optional and should not be used by the jwt library.
It defines the media type and could be used to disabiguate if you expect not only jwt tokens to hit your app. JWT stands for Json Web Tokens and JWS for Json Web Signature which is a different, but very similar rfc. In 99% of cases it does not matter and the reason my test token uses JWS is simply a coincidence.

@minjax
Copy link

minjax commented Jul 1, 2020

Continuing with the theme of API documentation/examples, the example given shows get_payload_claims() in this context:

      std::string token = "eyJhbGciOiJIUzI1...OkEE";
      auto decoded = jwt::decode(token);

      for( auto& e : decoded.get_payload_claims() )
          std::cout << e.first << " = " << e.second.to_json() << std::endl;

but, I don't find any definition of get_payload_claims() in class jwt::decoded_jwt<jwt::picojson_traits> or otherwise...

What am I missing here?

Thanks,

@prince-chrismc
Copy link
Collaborator

The current master is a getting ready for an release candidate, and rightfully so because it seem like get_payload_claims got removed during #71 by accident 😨

I would strongly recommend using the v0.4.0 release while the last few details get ironed out. ( I am using that in production code ) The method in question is available there.

std::unordered_map<std::string, claim> get_payload_claims() const { return payload_claims; }

Sorry for the inconvience!

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