10 stable releases
3.0.1 | Mar 17, 2024 |
---|---|
3.0.0 | Oct 25, 2021 |
2.3.0 | Sep 5, 2021 |
2.2.0 | Apr 30, 2020 |
1.0.1 | Aug 27, 2019 |
#8 in #key-id
58 downloads per month
13KB
156 lines
github-app-auth
This tool is no longer under active development. If you are interested in taking over or repurposing the name on crates.io, feel free to contact me: nbishop@nbishop.net
This is a small library for authenticating with the GitHub API as a GitHub app.
Documentation on the overall flow: https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps
lib.rs
:
This crate provides a library for authenticating with the GitHub API as a GitHub app. See Authenticating with GitHub Apps for details about the authentication flow.
Example:
use github_app_auth::{GithubAuthParams, InstallationAccessToken};
// The token is mutable because the installation access token must be
// periodically refreshed. See the `GithubAuthParams` documentation
// for details on how to get the private key and the two IDs.
let mut token = InstallationAccessToken::new(GithubAuthParams {
user_agent: "my-cool-user-agent".into(),
private_key: b"my private key".to_vec(),
app_id: 1234,
installation_id: 5678,
}).await.expect("failed to get installation access token");
// Getting the authentication header will automatically refresh
// the token if necessary, but of course this operation can fail.
let header = token.header().await.expect("failed to get authentication header");
token.client.post("https://some-github-api-url").headers(header).send().await;
Dependencies
~11–24MB
~466K SLoC