Skip to main content

OAuthError

Struct OAuthError 

Source
pub struct OAuthError {
    pub code: OAuthErrorCode,
    pub description: Option<String>,
    pub uri: Option<String>,
    pub state: Option<String>,
}
Expand description

An OAuth error: a code, and an optional description for a human.

Fields§

§code: OAuthErrorCode§description: Option<String>§uri: Option<String>§state: Option<String>

Echoed back on a redirect, so the client can match the response to the request it made.

Implementations§

Source§

impl OAuthError

Source

pub fn new(code: OAuthErrorCode) -> Self

Source

pub fn because(code: OAuthErrorCode, description: impl Into<String>) -> Self

The description is shown to developers, so say what is actually wrong.

It must never quote the offending secret back — an error body ends up in logs, browser history and bug reports.

Source

pub fn invalid_request(description: impl Into<String>) -> Self

Source

pub fn invalid_client(description: impl Into<String>) -> Self

Source

pub fn invalid_grant(description: impl Into<String>) -> Self

Source

pub fn invalid_scope(description: impl Into<String>) -> Self

Source

pub fn server_error(description: impl Into<String>) -> Self

Source

pub fn with_state(self, state: Option<String>) -> Self

Source

pub fn with_uri(self, uri: impl Into<String>) -> Self

Source

pub fn from_json(body: &Json) -> Option<OAuthError>

Read an error out of a provider’s JSON response.

Providers are not uniform here: some send a bare string, some an object, and some send 200 OK with an error body. The client checks for the field regardless of status, which is why this is lenient.

Source

pub fn to_json(&self) -> Json

Source

pub fn to_query(&self) -> String

The error=... query string appended to a redirect URI, per §4.1.2.1.

Trait Implementations§

Source§

impl Clone for OAuthError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OAuthError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for OAuthError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for OAuthError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<OAuthError> for Error

Source§

fn from(error: OAuthError) -> Error

Converts to this type from the input type.
Source§

impl From<StateError> for OAuthError

Every state failure is invalid_request: the callback was malformed as a request, whatever the reason, and saying which reason to the provider would be describing our own defence to whoever tripped it.

Source§

fn from(error: StateError) -> OAuthError

Converts to this type from the input type.
Source§

impl IntoResponse for OAuthError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.