resolve_token

Function resolve_token 

Source
pub async fn resolve_token(port: &impl AuthPort) -> Result<String, AuthError>
Expand description

Resolve a live access-token string from an AuthPort.

  1. Calls load_token().
  2. If the token is expired, calls refresh_token().
  3. Returns the raw access token string, ready to be injected into a request.

§Errors

Returns Err if no token exists, storage is unavailable, or refresh fails.

§Example

let auth = Env;
let token = resolve_token(&auth).await?;
println!("Bearer {token}");