Getting started Community Training Tutorials Documentation APIs, AI & Tools
use pdk::token_introspection::{IntrospectionResult, ParsedToken, ScopesValidator, TokenValidator, TokenValidatorBuilder};
#[entrypoint]
async fn configure(
launcher: Launcher,
Configuration(bytes): Configuration,
validator_builder: TokenValidatorBuilder,
) -> Result<()> {
// [...]
// Create a token validator
let mut validator_instance = validator_builder
.new("token-cache")
.with_path("/introspect")
.with_authorization_value("Basic YWRtaW46YWRtaW4=") // Choose either authorization value or client ID and secret depending on your service authorization. No authorization header is sent if with_authorization_value() isn't defined.
.with_client_id("client-id") // Client ID and secret are sent as form params in the body of the request
.with_client_secret("client-secret")
.with_expires_in_attribute("exp")
.with_max_token_ttl(600)
.with_timeout_ms(10000)
.with_max_cache_entries(10000)
.with_scopes_validator(ScopesValidator::all(scopes_vector))
.with_service(config.my_service)
.with_protected_resource_metadata(config.auth_server_url) // Choose .with_protected_resource_metadata_with_properties() if additional properties are required
.build();
// [...]
}



