Build the api client for this invocation, resolving the auth token from the most specific source available. This is the single source of truth for token resolution; the result lives on the returned client and every downstream consumer (GraphQL queries, upload `Authorization` header, executor env injection) reads it from there. Priority (most specific first): 1. `--token` / `CODSPEED_TOKEN`
(cli: &Cli, config: &CodSpeedConfig)
| 242 | /// 2. `--oauth-token` / `CODSPEED_OAUTH_TOKEN` and the persisted CLI |
| 243 | /// token from the selected profile. |
| 244 | fn build_api_client(cli: &Cli, config: &CodSpeedConfig) -> CodSpeedAPIClient { |
| 245 | let explicit = match &cli.command { |
| 246 | Commands::Run(args) => args.shared.token.clone(), |
| 247 | Commands::Exec(args) => args.shared.token.clone(), |
| 248 | _ => None, |
| 249 | }; |
| 250 | let token = match explicit { |
| 251 | Some(token) => Some(token), |
| 252 | None => config.auth.token.clone(), |
| 253 | }; |
| 254 | CodSpeedAPIClient::new(token, config.api_url.clone()) |
| 255 | } |