#[non_exhaustive]pub enum OAuthError {
MissingToken,
InvalidToken {
description: String,
},
InsufficientScope {
required: Vec<String>,
provided: Vec<String>,
},
InvalidAudience,
ExpiredToken,
}Expand description
OAuth 2.1 authentication/authorization error.
Each variant maps to a specific HTTP status code and WWW-Authenticate
header value per RFC 6750 Section 3.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingToken
No bearer token was provided in the request.
Returns HTTP 401 with WWW-Authenticate: Bearer.
InvalidToken
The provided token is invalid (malformed, signature mismatch, etc.).
Returns HTTP 401 with error="invalid_token".
InsufficientScope
The token’s scopes are insufficient for the requested operation.
Returns HTTP 403 with error="insufficient_scope".
Fields
InvalidAudience
The token’s audience does not match this resource server.
Returns HTTP 401 with error="invalid_token".
ExpiredToken
The token has expired.
Returns HTTP 401 with error="invalid_token".
Implementations§
Source§impl OAuthError
impl OAuthError
Sourcepub fn status_code(&self) -> u16
pub fn status_code(&self) -> u16
Returns the HTTP status code for this error.
- 401 Unauthorized for authentication failures (missing/invalid/expired token)
- 403 Forbidden for authorization failures (insufficient scope)
Sourcepub fn www_authenticate(&self, resource_metadata_url: Option<&str>) -> String
pub fn www_authenticate(&self, resource_metadata_url: Option<&str>) -> String
Builds the WWW-Authenticate header value per RFC 6750 Section 3.
When resource_metadata_url is provided, includes the resource_metadata
parameter per RFC 9728 so clients can discover the authorization server.
Trait Implementations§
Source§impl Clone for OAuthError
impl Clone for OAuthError
Source§fn clone(&self) -> OAuthError
fn clone(&self) -> OAuthError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OAuthError
impl Debug for OAuthError
Source§impl Display for OAuthError
impl Display for OAuthError
Source§impl Error for OAuthError
impl Error for OAuthError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()