Skip to content

Commit 61fb03f

Browse files
committed
fix: read token_file during initial auth in from_source
1 parent c93c74b commit 61fb03f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/hub_api.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,20 @@ impl HubApiClient {
278278
let (client, head_client) = make_clients();
279279
let endpoint = endpoint.trim_end_matches('/').to_string();
280280

281+
// Read token from file if no inline token was provided.
282+
let file_token = if token.is_none() {
283+
token_file
284+
.as_ref()
285+
.and_then(|p| std::fs::read_to_string(p).ok())
286+
.map(|s| s.trim().to_string())
287+
.filter(|s| !s.is_empty())
288+
} else {
289+
None
290+
};
291+
let effective_token: Option<&str> = token.or(file_token.as_deref());
292+
281293
let auth = |req: reqwest::RequestBuilder| -> reqwest::RequestBuilder {
282-
match token {
294+
match effective_token {
283295
Some(t) => req.bearer_auth(t),
284296
None => req,
285297
}

0 commit comments

Comments
 (0)