Template Function jwt::decode(const jwt::string_view, const params::detail::algorithms_param<SequenceT>&, std::error_code&, Args&&…)

Function Documentation

template<typename SequenceT, typename ...Args>
jwt_object jwt::decode(const jwt::string_view enc_str, const params::detail::algorithms_param<SequenceT> &algos, std::error_code &ec, Args&&... args)

Decode the JWT signature to create the jwt_object. This version reports error back using std::error_code.

If any of the registered claims are found in wrong format then sets TypeConversion error in the error_code.

NOTE: Memory allocation exceptions are not caught.

Optional parameters that can be passed:

  1. verify : A boolean flag to indicate whether the signature should be verified or not. Set to true by default.

  2. leeway : Number of seconds that can be added (in case of exp) or subtracted (in case of nbf) to be more lenient. Set to 0 by default.

  3. algorithms : Takes in a sequence of algorithms which the client expects the signature to be decoded with.

  4. aud : The audience the client expects to be in the claim. NOTE: It is case-sensitive.

  5. issuer: The issuer the client expects to be in the claim. NOTE: It is case-sensitive

  6. sub: The subject the client expects to be in the claim.

  7. validate_iat: Checks if IAT claim is present or not and the type is uint64_t or not. If claim is not present then set InvalidIAT error.

  8. validate_jti: Checks if jti claim is present or not.