Crates.io | keycloak-oauth |
lib.rs | keycloak-oauth |
version | 0.0.2 |
source | src |
created_at | 2024-10-17 13:57:04.21563 |
updated_at | 2024-10-17 20:51:12.322226 |
description | Library designed for seamless integration with Keycloak's OAuth2 authentication flows |
homepage | |
repository | https://github.com/buhaytza2005/keycloak-oauth |
max_upload_size | |
id | 1413223 |
size | 78,112 |
keycloak-oauth is a basic Rust library designed to facilitate seamless integration with Keycloak's OAuth2 authentication flows.
Currently only supports device authentication flow.
[!CAUTION] The flow currently temporarily caches a token on disk in
.temp_files/token.json
. This will be upgraded to libsecret in the future
use keycloak_oauth::{ClientConfiguration, KeycloakClient, ClientError};
#[tokio::main]
async fn main() -> Result<(), ClientError> {
// Load configuration from environment variables or another source
let config = ClientConfiguration::from_env();
// Initialize the KeycloakClient
let keycloak_client = KeycloakClient::new(config);
// Authenticate and obtain the access token
let access_token = keycloak_client.verify_and_refresh_token().await?;
// Use the access token as needed
println!("Obtained Access Token: {}", access_token);
Ok(())
}
This project is licensed under the MIT License.