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)
| 422 | /// validity without conflating it with repository-level access checks — |
| 423 | /// those are done with [`Self::session_and_repository_overview`]. |
| 424 | pub async fn session(&self) -> std::result::Result<SessionPayload, SessionError> { |
| 425 | let response = self |
| 426 | .gql_client |
| 427 | .query_unwrap::<SessionData>(include_str!("queries/Session.gql")) |
| 428 | .await; |
| 429 | match response { |
| 430 | Ok(data) => Ok(data.session), |
| 431 | Err(err) |
| 432 | if err.contains_error_code("UNAUTHENTICATED") |
| 433 | || err.contains_error_code("UNAUTHORIZED") => |
| 434 | { |
| 435 | Err(SessionError::Unauthenticated) |
| 436 | } |
| 437 | Err(err) => Err(SessionError::Other(anyhow!( |
| 438 | "Failed to validate token: {err}" |
| 439 | ))), |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | /// Validate the token and look up a candidate repository in one |
| 444 | /// round-trip. Used by `auth status` (with a detected git remote) and |
no outgoing calls
no test coverage detected