pub struct DcrClient { /* private fields */ }Expand description
Dynamic Client Registration client
§Example
use turbomcp_auth::oauth2::dcr::{DcrClient, DcrBuilder};
let client = DcrClient::new(
"https://auth.example.com/register".to_string(),
None,
);
let request = DcrBuilder::mcp_client("My App", "http://localhost:3000/callback")
.with_scopes(vec!["mcp:tools".to_string()])
.build();
let response = client.register(request).await?;
println!("Registered! Client ID: {}", response.client_id);Implementations§
Source§impl DcrClient
impl DcrClient
Sourcepub fn new(endpoint: String, initial_access_token: Option<String>) -> Self
pub fn new(endpoint: String, initial_access_token: Option<String>) -> Self
Create a new DCR client
§Arguments
endpoint- Registration endpoint URL (from AS metadataregistration_endpoint)initial_access_token- Optional token for authenticated registration
§Example
use turbomcp_auth::oauth2::dcr::DcrClient;
// Open registration (no token required)
let client = DcrClient::new(
"https://auth.example.com/register".to_string(),
None,
);
// Authenticated registration
let auth_client = DcrClient::new(
"https://auth.example.com/register".to_string(),
Some("initial_access_token_here".to_string()),
);Sourcepub async fn register(
&self,
request: RegistrationRequest,
) -> McpResult<RegistrationResponse>
pub async fn register( &self, request: RegistrationRequest, ) -> McpResult<RegistrationResponse>
Register a new OAuth client
§Arguments
request- Client registration metadata
§Returns
Registration response with client_id, client_secret, and metadata
§Errors
Returns error if:
- HTTP request fails
- Server rejects registration
- Response is malformed
§Example
let request = DcrBuilder::mcp_client("My App", "http://localhost:3000/callback")
.build();
let response = client.register(request).await?;Sourcepub async fn update(
&self,
registration_uri: &str,
access_token: &str,
request: RegistrationRequest,
) -> McpResult<RegistrationResponse>
pub async fn update( &self, registration_uri: &str, access_token: &str, request: RegistrationRequest, ) -> McpResult<RegistrationResponse>
Update an existing client registration (RFC 7592)
Requires the registration_access_token from the original registration.
§Example
// Update the registration
let updated = DcrBuilder::mcp_client("Updated App Name", "http://localhost:3000/callback")
.with_scopes(vec!["mcp:tools".to_string(), "mcp:resources".to_string()])
.build();
let response = client.update(
&original_response.registration_client_uri.unwrap(),
&original_response.registration_access_token.unwrap(),
updated,
).await?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for DcrClient
impl !RefUnwindSafe for DcrClient
impl Send for DcrClient
impl Sync for DcrClient
impl Unpin for DcrClient
impl !UnwindSafe for DcrClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more