main.cpp (1600B)
1 #include <spdlog/spdlog.h> 2 3 #include "matrix_coro.hpp" 4 #include "cppcoro/sync_wait.hpp" 5 6 int main() { 7 spdlog::set_level(spdlog::level::debug); 8 spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v"); 9 10 Client client; 11 12 const auto homeserver = "https://synapse-oidc.element.dev"; 13 auto redirect_url = "https://areweoidcyet.com/client-implementation-guide/callback"; 14 const auto state = "state"; 15 const auto code_verifier = 16 "ahlae7FuMahCeeseip6Shooqu6aefai5xoocea5gav2"; 17 ClientRegistrationData registration_data; 18 registration_data.application_type = "web"; 19 registration_data.client_name = "Test"; 20 registration_data.client_uri = "https://areweoidcyet.com/"; 21 registration_data.token_endpoint_auth_method = "none"; 22 registration_data.redirect_uris = {redirect_url}; 23 registration_data.response_types = {"code"}; 24 registration_data.grant_types = {"authorization_code", "refresh_token"}; 25 registration_data.contacts = {"mailto:hello@localhost"}; 26 27 auto auth_url_task = client.get_auth_url(homeserver, redirect_url, state, code_verifier, registration_data); 28 29 auto auth_url = sync_wait(auth_url_task); 30 31 spdlog::info("Please login via the Auth URL: {}", auth_url); 32 33 // Wait for the user to paste the code here 34 std::string code; 35 spdlog::info("Please paste the code here: "); 36 std::cin >> code; 37 38 const auto logged_in_client = sync_wait(client.exchange_token(code, redirect_url)); 39 40 const auto whoami = sync_wait(logged_in_client.whoami()); 41 42 spdlog::info("User ID: {}", whoami.user_id); 43 44 return 0; 45 }