From 3a29ecaa36c7125838e651b7f7ea8d8fe5209ac6 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Tue, 28 Mar 2023 20:20:11 +1100 Subject: [PATCH] Support GitHub fine-grained personal access token (#957) Signed-off-by: Jiahao XU --- crates/binstalk-downloader/src/gh_api_client.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/binstalk-downloader/src/gh_api_client.rs b/crates/binstalk-downloader/src/gh_api_client.rs index 649817a6..a2c70658 100644 --- a/crates/binstalk-downloader/src/gh_api_client.rs +++ b/crates/binstalk-downloader/src/gh_api_client.rs @@ -99,6 +99,7 @@ pub struct GhApiClient(Arc); fn gh_prefixed(token: &str) -> bool { matches!((token.get(0..2), token.get(3..4)), (Some("gh"), Some("_"))) + || token.starts_with("github_") } impl GhApiClient { @@ -107,7 +108,7 @@ impl GhApiClient { if gh_prefixed(&auth_token) { Some(auth_token) } else { - warn!("Invalid auth_token, expected 'gh*_', fallback to unauthorized mode"); + warn!("Invalid auth_token, expected 'gh*_' or `github_*`, fallback to unauthorized mode"); None } });