arun11299 / cpp-jwt

JSON Web Token library for C++
MIT License
393 stars 112 forks source link

Error when calling the function "get_claim_value" #48

Closed kwegener1 closed 5 years ago

kwegener1 commented 5 years ago

Hello, I'm in it and testing your library. The decoding worked. Now I would like to read out a value via the function get_claim_value().

std::error_code ec; auto decodeObj = jwt::decode(strFeatures.toStdString(), algorithms({"RS256"}), ec, secret(keyPublicKey.toStdString()));

jwt::string_view claimName = "Webvisu"; auto claimValue = decodeObj.payload().get_claim_value(claimName); std::cout << claimValue << std::endl;

I get the following error: image

Next I tested the following: jwt::string_view claimName = "Webvisu"; auto claimValue = decodeObj.payload().get_claim_value<const jwt::string_view>(claimName); std::cout << claimValue << std::endl;

And get this error: image

arun11299 commented 5 years ago

Just seeing it now. I will take a look at it and get back.

arun11299 commented 5 years ago

The first error is because you need to explicitly provide the template parameter. There is no type deduction happening there as the type 'T' is not being used as the function argument.

As for the second case, its the nlohmann json library having some issue in supporting jwt::string_view. I will have to look into it. By that time, can you try doing:

auto claimValue = decodeObj.payload().get_claim_value<std::string>(claimName);
kwegener1 commented 5 years ago

It works!