mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Support GitHub fine-grained personal access token (#957)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
0fa729d742
commit
3a29ecaa36
1 changed files with 2 additions and 1 deletions
|
@ -99,6 +99,7 @@ pub struct GhApiClient(Arc<Inner>);
|
||||||
|
|
||||||
fn gh_prefixed(token: &str) -> bool {
|
fn gh_prefixed(token: &str) -> bool {
|
||||||
matches!((token.get(0..2), token.get(3..4)), (Some("gh"), Some("_")))
|
matches!((token.get(0..2), token.get(3..4)), (Some("gh"), Some("_")))
|
||||||
|
|| token.starts_with("github_")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GhApiClient {
|
impl GhApiClient {
|
||||||
|
@ -107,7 +108,7 @@ impl GhApiClient {
|
||||||
if gh_prefixed(&auth_token) {
|
if gh_prefixed(&auth_token) {
|
||||||
Some(auth_token)
|
Some(auth_token)
|
||||||
} else {
|
} else {
|
||||||
warn!("Invalid auth_token, expected 'gh*_', fallback to unauthorized mode");
|
warn!("Invalid auth_token, expected 'gh*_' or `github_*`, fallback to unauthorized mode");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue