Overview

The fetch_jwt_templates function retrieves all JWT (JSON Web Token) templates configured for your deployment.

Function Signature

pub async fn fetch_jwt_templates() -> Result<JwtTemplateListResponse>

Parameters

This function takes no parameters.

Return Value

Returns Result<JwtTemplateListResponse> containing:
  • data: Vector of JwtTemplate objects

Basic Usage

use wacht::api::settings::*;

let templates = fetch_jwt_templates().await?;
println!("Found {} JWT templates", templates.data.len());

for template in templates.data {
    println!("Template: {} ({})", template.name, template.id);
    println!("  Algorithm: {}", template.algorithm);
    println!("  Claims: {:?}", template.claims);
}

Error Handling

match fetch_jwt_templates().await {
    Ok(response) => {
        println!("Successfully retrieved {} JWT templates", response.data.len());
        for template in response.data {
            println!("- {} (expires in: {} seconds)", template.name, template.expires_in);
        }
    }
    Err(Error::Api { status, message, .. }) => {
        match status.as_u16() {
            403 => println!("Access denied: {}", message),
            _ => println!("API error {}: {}", status, message),
        }
    }
    Err(e) => println!("Request failed: {}", e),
}

Rate Limits

  • Read operations: 100 requests per minute
  • Burst limit: 20 requests per second