mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-12-03 09:17:38 +00:00
prototype for FindPackage install
This commit is contained in:
7
example/CMakeLists.txt
Normal file
7
example/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(jwt-cpp-test)
|
||||
|
||||
find_package(jwt-cpp REQUIRED)
|
||||
|
||||
add_executable(jwt-cpp-test print-claims.cpp)
|
||||
target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp:jwt-cpp)
|
||||
10
example/print-claims.cpp
Normal file
10
example/print-claims.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <jwt-cpp/jwt.h>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
std::string token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
|
||||
auto decoded = jwt::decode(token);
|
||||
|
||||
for(auto& e : decoded.get_payload_claims())
|
||||
std::cout << e.first << " = " << e.second.to_json() << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user