Skip to content
JSON Web Token C++ lib
C++ C
Find file
Latest commit 46fb341 @almet Yeah. signing works!
Failed to load latest commit information.
src Yeah. signing works!
Makefile import some code
README.rst README formatting
TODO Yeah. signing works!


JSON Web Tokens C++ lib


This library is a work in progress. It's not ready for production yet.

This lib exposes a simple class to work with signed JSON Web Tokens (JWT). It had been developped by Mozilla while making a C++ implementation of BrowserID.

JSON Web Tokens (JWT) are described in this document


Running make and make install should do the trick.


You need to have the following library installed on your system:

  • cryptopp for the crypto related stuff
  • jansson to deal with json

How to use it?

Once installed, jwtcpp provides a bunch of functions and methods so you can extract information about the JSON Web Tokens.

Here is an example application showing how you can use the library:

# include "jwtcpp.h"

using namespace std;

// It is possible to create a JWT from a string and to interact with it

JWT* jwt = JWT::fromString();
cout << jwt->algorithm << endl;
cout << jwt->signature << endl;
cout << jwt->signed_data << endl;

json_t* payload = jwt->payload;

// It is also possible to create a JWT programatically and then serialize
// it as a string
string serialized = jwt->generate(key);

// There is also a static method available if you want to directly
// serialize a mapping
Jwt* jwt = JWT::generate(mapping, key);

jwtcpp also provides a cli application able to generate and decode JWT. You can invoke it like this:

$ jwtcpp --generate --key=path/to/key.crt --data="{'json data': true}"
XXX the output here

$ jwtcpp --extract | cat token.jwt
XXX output

$ jwtcpp --extract --data "yourcontenthere"
XXX output
Something went wrong with that request. Please try again.