Skip to main content

token

Function token 

Source
pub async fn token(
    __arg0: State<ApiState>,
    __arg1: Json<TokenRequest>,
) -> ApiResponse<TokenResponse>
Expand description

POST /oauth/token — exchange an authorization code or refresh token for an access token (RFC 6749 §4.1.3, §6).

Supported grant types:

  • authorization_code — requires code, client_id, and optionally code_verifier
  • refresh_token — requires refresh_token

§Example

// POST /oauth/token {"grant_type":"authorization_code","code":"ac_...","client_id":"..."}
let response = token(State(api_state), Json(token_request)).await;
assert!(response.success);