pub struct OAuthAuth {
pub grant_type: OAuthGrantType,
pub token_url: String,
pub client_id: String,
pub client_secret: Option<String>,
pub scope: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub authorization_url: Option<String>,
pub redirect_uri: Option<String>,
}Expand description
Auth::oauth: acquire a bearer token from an OAuth token endpoint
before the request is sent, under one of three grants.
auth:
oauth:
grant_type: client_credentials # or: password, authorization_code
token_url: https://auth.example.com/token
client_id: {{client_id}}
client_secret: {{client_secret}}
scope: read write # optional
# required only for grant_type: password
username: {{username}}
password: {{password}}
# required only for grant_type: authorization_code
authorization_url: https://auth.example.com/authorize
redirect_uri: http://127.0.0.1:8899/callbackclient_credentials and password are acquired automatically —
crate::Request::resolve_oauth fetches (or reuses a cached) token
before every send with no human involved. authorization_code cannot
work that way: it needs a human to approve access in a browser, so
resolve_oauth refuses to attempt it automatically and instead reports a
clear error directing the caller to log in interactively first. The TUI
is the one caller that can do that — see crate::oauth’s module docs
for the interactive flow and why client_secret is optional only for
this grant (a desktop client cannot keep a secret confidential, so PKCE
stands in for it; see RFC 8252 §8.1/§8.5).
crate::Request::resolve_oauth acquires the token — through
crate::oauth::OAuthTokenCache, reusing one already acquired for the
same token_url/client_id/grant_type/scope within this run rather
than re-authenticating per request — and hands it to the exact same
Authorization: Bearer code path Auth::bearer already resolves to;
see crate::Request::resolve_auth.
Fields§
§grant_type: OAuthGrantType§token_url: String§client_id: String§client_secret: Option<String>Required for OAuthGrantType::ClientCredentials and
OAuthGrantType::Password; optional for
OAuthGrantType::AuthorizationCode, whose native/desktop clients
typically have none — see validate_grant_fields.
scope: Option<String>§username: Option<String>Required when grant_type is
OAuthGrantType::Password — see validate_grant_fields.
password: Option<String>Required when grant_type is
OAuthGrantType::Password — see validate_grant_fields.
The provider’s authorization endpoint — where the browser is sent to
let the user approve access. Required when
grant_type is
OAuthGrantType::AuthorizationCode; unused by the other two grants,
which never open a browser. See validate_grant_fields.
redirect_uri: Option<String>Where the provider redirects back with the authorization code — must
match what is registered with the provider. Required when
grant_type is
OAuthGrantType::AuthorizationCode; the TUI’s local callback
listener binds to this exact address. See
validate_grant_fields.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OAuthAuth
impl<'de> Deserialize<'de> for OAuthAuth
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for OAuthAuth
impl StructuralPartialEq for OAuthAuth
Auto Trait Implementations§
impl Freeze for OAuthAuth
impl RefUnwindSafe for OAuthAuth
impl Send for OAuthAuth
impl Sync for OAuthAuth
impl Unpin for OAuthAuth
impl UnsafeUnpin for OAuthAuth
impl UnwindSafe for OAuthAuth
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.