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
impl OAuthError
pub fn new(code: OAuthErrorCode) -> Self
Sourcepub fn because(code: OAuthErrorCode, description: impl Into<String>) -> Self
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.
pub fn invalid_request(description: impl Into<String>) -> Self
pub fn invalid_client(description: impl Into<String>) -> Self
pub fn invalid_grant(description: impl Into<String>) -> Self
pub fn invalid_scope(description: impl Into<String>) -> Self
pub fn server_error(description: impl Into<String>) -> Self
pub fn with_state(self, state: Option<String>) -> Self
pub fn with_uri(self, uri: impl Into<String>) -> Self
Sourcepub fn from_json(body: &Json) -> Option<OAuthError>
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.
pub fn to_json(&self) -> Json
Trait Implementations§
Source§impl Clone for OAuthError
impl Clone for OAuthError
Source§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()
Source§impl From<OAuthError> for Error
impl From<OAuthError> for Error
Source§fn from(error: OAuthError) -> Error
fn from(error: OAuthError) -> Error
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.
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.