#github #app #authentication

github-app-auth

Library for authenticating as a GitHub app

9 stable releases

Uses new Rust 2021

3.0.0 Oct 25, 2021
2.3.0 Sep 5, 2021
2.2.0 Apr 30, 2020
1.2.1 Jan 9, 2020
1.0.1 Aug 27, 2019

#128 in Authentication

Download history 64/week @ 2022-01-24 63/week @ 2022-01-31 46/week @ 2022-02-07 51/week @ 2022-02-14 67/week @ 2022-02-21 7/week @ 2022-02-28 4/week @ 2022-03-07 44/week @ 2022-03-14 33/week @ 2022-03-21 10/week @ 2022-03-28 18/week @ 2022-04-04 5/week @ 2022-04-11 6/week @ 2022-04-18 49/week @ 2022-04-25 53/week @ 2022-05-02 12/week @ 2022-05-09

124 downloads per month

Apache-2.0

12KB
156 lines

github-app-auth

crates.io Documentation

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};

# async fn wrapper() {
// 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;
# }  // End wrapper

Dependencies

~10–20MB
~465K SLoC