Skip to main content

Crate ghtkn

Crate ghtkn 

Source
Expand description

GitHub token management via OAuth device flow.

ghtkn provides a complete SDK for obtaining GitHub access tokens through the OAuth device authorization grant flow (RFC 8628). Tokens are cached in the system keyring for reuse across sessions.

§Quick start

use ghtkn::{Client, InputGet};

let client = Client::new();
let (token, app) = client.get(&InputGet::default()).await?;
println!("Token for {}: {}...", app.name, &token.access_token[..8]);

Re-exports§

pub use api::Client;
pub use api::InputGet;
pub use api::TokenSource;
pub use browser::Browser;
pub use browser::BrowserError;
pub use browser::DefaultBrowser;
pub use config::App;
pub use config::Config;
pub use deviceflow::DeviceCodeResponse;
pub use deviceflow::DeviceCodeUI;
pub use deviceflow::SimpleDeviceCodeUI;
pub use error::Error;
pub use error::Result;
pub use github::GitHubClient;
pub use keyring::AccessToken;
pub use keyring::DEFAULT_SERVICE_KEY;
pub use log::Logger;

Modules§

api
Token manager and public client API.
browser
Cross-platform browser opening.
config
Configuration management for ghtkn.
deviceflow
OAuth device flow protocol for GitHub access tokens.
error
github
GitHub API client for authenticated requests.
keyring
Keyring integration for token caching.
log
Customizable logging callbacks for the token flow.

Functions§

get_config_path
Return the default config file path for the current platform.