Skip to main content

exchange_code_for_token

Function exchange_code_for_token 

Source
pub async fn exchange_code_for_token(
    code: &str,
    challenge: &PkceChallenge,
) -> Result<String>
Expand description

Exchange an authorization code for an API key.

This makes a POST request to OpenRouter’s token endpoint with the authorization code and PKCE verifier.

§Arguments

  • code - The authorization code from the callback URL
  • challenge - The PKCE challenge used during authorization

§Returns

The obtained API key on success.