pub struct OAuthClient { /* private fields */ }Expand description
OAuth 2.1 client for server discovery and registration
Implementations§
Source§impl OAuthClient
impl OAuthClient
pub fn new( client_id: String, client_secret: String, auth_url: String, ) -> OAuthClient
pub fn from_config(config: OAuthConfig) -> OAuthClient
pub fn client_id(&self) -> &str
pub fn auth_url(&self) -> &str
pub fn client_secret(&self) -> &str
Sourcepub async fn discover_server_metadata(
&self,
issuer: &str,
) -> Result<AuthorizationServerMetadata, AuthError>
pub async fn discover_server_metadata( &self, issuer: &str, ) -> Result<AuthorizationServerMetadata, AuthError>
Discover authorization server metadata (RFC 8414)
Sourcepub async fn register_client(
&self,
registration_endpoint: &str,
request: ClientRegistrationRequest,
) -> Result<ClientRegistrationResponse, AuthError>
pub async fn register_client( &self, registration_endpoint: &str, request: ClientRegistrationRequest, ) -> Result<ClientRegistrationResponse, AuthError>
Register a dynamic client (RFC 7591)
Build authorization URL with PKCE
Sourcepub async fn exchange_code_for_token(
&self,
token_endpoint: &str,
client_id: &str,
client_secret: Option<&str>,
redirect_uri: &str,
authorization_code: &str,
code_verifier: &str,
) -> Result<TokenResponse, AuthError>
pub async fn exchange_code_for_token( &self, token_endpoint: &str, client_id: &str, client_secret: Option<&str>, redirect_uri: &str, authorization_code: &str, code_verifier: &str, ) -> Result<TokenResponse, AuthError>
Exchange authorization code for access token
Sourcepub async fn refresh_token(
&self,
token_endpoint: &str,
client_id: &str,
client_secret: Option<&str>,
refresh_token: &str,
) -> Result<TokenResponse, AuthError>
pub async fn refresh_token( &self, token_endpoint: &str, client_id: &str, client_secret: Option<&str>, refresh_token: &str, ) -> Result<TokenResponse, AuthError>
Refresh an access token using a refresh token
Trait Implementations§
Source§impl Default for OAuthClient
impl Default for OAuthClient
Source§fn default() -> OAuthClient
fn default() -> OAuthClient
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OAuthClient
impl !RefUnwindSafe for OAuthClient
impl Send for OAuthClient
impl Sync for OAuthClient
impl Unpin for OAuthClient
impl !UnwindSafe for OAuthClient
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