pub struct OAuth2Config {
pub client_id: String,
pub client_secret: Option<String>,
pub token_url: String,
pub scopes: Vec<String>,
/* private fields */
}Expand description
OAuth2 configuration for MCP authentication
Fields§
§client_id: StringOAuth2 client ID
client_secret: Option<String>OAuth2 client secret (optional for public clients)
token_url: StringToken endpoint URL
scopes: Vec<String>Requested scopes
Implementations§
Source§impl OAuth2Config
impl OAuth2Config
Sourcepub fn new(client_id: impl Into<String>, token_url: impl Into<String>) -> Self
pub fn new(client_id: impl Into<String>, token_url: impl Into<String>) -> Self
Create a new OAuth2 config
Sourcepub fn with_secret(self, secret: impl Into<String>) -> Self
pub fn with_secret(self, secret: impl Into<String>) -> Self
Set client secret
Sourcepub fn with_scopes(self, scopes: Vec<String>) -> Self
pub fn with_scopes(self, scopes: Vec<String>) -> Self
Add scopes
Sourcepub async fn get_or_refresh_token(&self) -> Result<String, AuthError>
pub async fn get_or_refresh_token(&self) -> Result<String, AuthError>
Get or refresh the access token
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear the token cache (force refresh on next request)
Auto Trait Implementations§
impl !Freeze for OAuth2Config
impl !RefUnwindSafe for OAuth2Config
impl Send for OAuth2Config
impl Sync for OAuth2Config
impl Unpin for OAuth2Config
impl UnsafeUnpin for OAuth2Config
impl UnwindSafe for OAuth2Config
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request