pub struct OAuth2Config {
pub client_id: String,
pub client_secret: Option<String>,
pub token_url: String,
pub scopes: Vec<String>,
/* private fields */
}Available on crate feature
tools only.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>,
) -> OAuth2Config
pub fn new( client_id: impl Into<String>, token_url: impl Into<String>, ) -> OAuth2Config
Create a new OAuth2 config
Sourcepub fn with_secret(self, secret: impl Into<String>) -> OAuth2Config
pub fn with_secret(self, secret: impl Into<String>) -> OAuth2Config
Set client secret
Sourcepub fn with_scopes(self, scopes: Vec<String>) -> OAuth2Config
pub fn with_scopes(self, scopes: Vec<String>) -> OAuth2Config
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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::RequestCreates a shared type from an unshared type.