pub async fn fetch_jwks(oidc_url: &str) -> Result<Value>
Expand description
Fetches the JSON Web Key Set (JWKS) from the specified OIDC provider URL.
This function sends a GET request to the .well-known/jwks
endpoint of the provided OIDC URL
to retrieve the JSON Web Key Set (JWKS), which contains the public keys used to verify OIDC tokens.
§Arguments
oidc_url
- A string slice that holds the base URL of the OIDC provider.
§Returns
Result<Value>
- A Result containing the JWKS as a serde_json::Value if successful, or an error if the fetch or parsing fails.
§Errors
This function will return an error if:
- The HTTP request to fetch the JWKS fails
- The response cannot be parsed as valid JSON
§Example
use git_oidc::fetch_jwks;
use color_eyre::eyre::Result;
#[tokio::main]
async fn main() -> Result<()> {
let jwks = fetch_jwks("https://token.actions.githubusercontent.com").await?;
println!("Fetched JWKS: {:?}", jwks);
Ok(())
}