Support GitHub fine-grained personal access token (#957)

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-28 20:20:11 +11:00 committed by GitHub
parent 0fa729d742
commit 3a29ecaa36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,6 +99,7 @@ pub struct GhApiClient(Arc<Inner>);
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
}
});