get_api_token

Function get_api_token 

Source
pub async fn get_api_token(
    infra: &InfraContext<'_>,
    username: &str,
    password: &str,
) -> Result<String, Error>
Expand description

Exchange username + password for a CSM bearer token via the site’s configured backend.

The CLI’s auth command posts to /api/v1/auth/token, which reaches this function. The returned token is the same bearer the caller then sends as Authorization: Bearer ... on every subsequent request.

§Errors

Whatever the backend’s [AuthenticationTrait::get_api_token] returns — typically a BackendError::Unauthorized for bad credentials, or a NetError when the backend’s IDP is unreachable.