#[cfg(not(target_arch = "wasm32"))]
use xjp_oidc::{
http::ReqwestHttpClient,
introspect_token, revoke_token, refresh_token, get_userinfo,
IntrospectRequest, RefreshTokenRequest,
register_client, get_client_config,
RegisterRequest,
tenant::{TenantConfig, TenantMode},
};
#[cfg(not(target_arch = "wasm32"))]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let http = ReqwestHttpClient::default();
let issuer = "https://auth.xiaojinpro.com";
println!("=== xjp-oidc New Features Example ===\n");
println!("1. Token Introspection");
let introspect_req = IntrospectRequest {
issuer: issuer.to_string(),
client_id: "xjp-web".to_string(),
client_secret: Some("secret".to_string()),
token: "some-access-token".to_string(),
token_type_hint: Some("access_token".to_string()),
token_endpoint_auth_method: None,
};
println!(" Would introspect token at: {}/oauth2/introspect", issuer);
println!("\n2. Token Revocation");
println!(" Would revoke token at: {}/oauth2/revoke", issuer);
println!("\n3. Refresh Token");
let refresh_req = RefreshTokenRequest {
issuer: issuer.to_string(),
client_id: "xjp-web".to_string(),
client_secret: Some("secret".to_string()),
refresh_token: "some-refresh-token".to_string(),
scope: Some("openid profile email".to_string()),
token_endpoint_auth_method: None,
};
println!(" Would refresh token at: {}/oauth2/token", issuer);
println!("\n4. UserInfo Endpoint");
println!(" Would get user info at: {}/oidc/userinfo", issuer);
println!(" Note: Currently uses POST due to HttpClient limitation");
println!("\n5. DCR Get Client Configuration");
println!(" Would get client config at: {}/connect/register/{{client_id}}", issuer);
println!("\n6. Multi-tenant ClientId Mode");
let tenant_config = TenantConfig::client_id("xjp-web".to_string());
let discovery_url = format!("{}/.well-known/openid-configuration", issuer);
let tenant_url = tenant_config.apply_to_url(&discovery_url)?;
println!(" Original URL: {}", discovery_url);
println!(" Tenant URL: {}", tenant_url);
println!("\nNote: This example only demonstrates the API usage.");
println!("In a real application, you would actually call these functions with a running auth server.");
Ok(())
}
#[cfg(target_arch = "wasm32")]
fn main() {
println!("This example is only available on non-WASM platforms.");
}