mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
🗂️ Add Conan example (#119)
* conan example added * remove cmake overhead * Update conan-example/CMakeLists.txt change cmake version Co-authored-by: Chris Mc <prince.chrismc@gmail.com> Co-authored-by: Mehmet Ali Baykara <mehmetali.baykara@encoway.de> Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
This commit is contained in:
committed by
GitHub
parent
933fc1681f
commit
d2da74a80f
7
conan-example/CMakeLists.txt
Normal file
7
conan-example/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
project(conan-example)
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
|
||||
25
conan-example/README.md
Normal file
25
conan-example/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
Conan example
|
||||
|
||||
|
||||
In the current directory on Linux environment
|
||||
```
|
||||
mkdir build && cd build
|
||||
conan install .. && cmake ..
|
||||
cmake --build .
|
||||
```
|
||||
run executable
|
||||
```
|
||||
./bin/conan-example
|
||||
```
|
||||
the output:
|
||||
```
|
||||
sub = "jrocket@example.com"
|
||||
iss = "Online JWT Builder"
|
||||
exp = 1641559177
|
||||
aud = "www.example.com"
|
||||
Surname = "Rocket"
|
||||
Role = ["Manager","Project Administrator"]
|
||||
iat = 1610023177
|
||||
GivenName = "Johnny"
|
||||
Email = "jrocket@example.com"
|
||||
```
|
||||
5
conan-example/conanfile.txt
Normal file
5
conan-example/conanfile.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
[requires]
|
||||
jwt-cpp/0.4.0
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
15
conan-example/main.cpp
Normal file
15
conan-example/main.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include"jwt-cpp/jwt.h"
|
||||
#include<iostream>
|
||||
#include <chrono>
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
std::string token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2MTAwMjMxNzcsImV4cCI6MTY0MTU1OTE3NywiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIkdpdmVuTmFtZSI6IkpvaG5ueSIsIlN1cm5hbWUiOiJSb2NrZXQiLCJFbWFpbCI6Impyb2NrZXRAZXhhbXBsZS5jb20iLCJSb2xlIjpbIk1hbmFnZXIiLCJQcm9qZWN0IEFkbWluaXN0cmF0b3IiXX0.5EOfHnBmpdPvRHAuVDttgJQvbFuGEF7fC4uBSXAGg6c";
|
||||
|
||||
auto decoded = jwt::decode(token);
|
||||
|
||||
for(auto& e : decoded.get_payload_claims())
|
||||
std::cout << e.first << " = " << e.second << std::endl;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user