MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / session

Method session

src/api_client.rs:381–398  ·  view source on GitHub ↗

Introspect the token currently configured on this client. Returns the linked user (when applicable). Used to verify a token's validity without conflating it with repository-level access checks — those are done with [`Self::session_and_repository_overview`].

(&self)

Source from the content-addressed store, hash-verified

379 /// validity without conflating it with repository-level access checks —
380 /// those are done with [`Self::session_and_repository_overview`].
381 pub async fn session(&self) -> std::result::Result<SessionPayload, SessionError> {
382 let response = self
383 .gql_client
384 .query_unwrap::<SessionData>(include_str!("queries/Session.gql"))
385 .await;
386 match response {
387 Ok(data) => Ok(data.session),
388 Err(err)
389 if err.contains_error_code("UNAUTHENTICATED")
390 || err.contains_error_code("UNAUTHORIZED") =>
391 {
392 Err(SessionError::Unauthenticated)
393 }
394 Err(err) => Err(SessionError::Other(anyhow!(
395 "Failed to validate token: {err}"
396 ))),
397 }
398 }
399
400 /// Validate the token and look up a candidate repository in one
401 /// round-trip. Used by `auth status` (with a detected git remote) and

Callers 2

loginFunction · 0.80
resolve_auth_statusFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected