pub struct OAuthSession { /* private fields */ }Expand description
Manages the OAuth2 authorization process and token lifecycle for accessing the QCS API.
This struct encapsulates the necessary information to request an access token
from an authorization server, including the OAuth2 grant type and any associated
credentials or payload data.
§Fields
payload- TheOAuth2grant type and associated data that will be used to request an access token.access_token- The access token currently in use, if any. If no token has been provided or requested yet, this will beNone.auth_server- The authorization server responsible for issuing tokens.
Implementations§
Source§impl OAuthSession
impl OAuthSession
Sourcepub const fn new(
payload: OAuthGrant,
auth_server: AuthServer,
access_token: Option<String>,
) -> Self
pub const fn new( payload: OAuthGrant, auth_server: AuthServer, access_token: Option<String>, ) -> Self
Initialize a new set of [Credentials] using a [GrantPayload].
Optionally include an access_token, if not included, then one can be requested
with Self::request_access_token.
Sourcepub const fn from_externally_managed(
tokens: ExternallyManaged,
auth_server: AuthServer,
access_token: Option<String>,
) -> Self
pub const fn from_externally_managed( tokens: ExternallyManaged, auth_server: AuthServer, access_token: Option<String>, ) -> Self
Initialize a new set of [Credentials] using an ExternallyManaged.
Optionally include an access_token, if not included, then one can be requested
with Self::request_access_token.
Sourcepub const fn from_refresh_token(
tokens: RefreshToken,
auth_server: AuthServer,
access_token: Option<String>,
) -> Self
pub const fn from_refresh_token( tokens: RefreshToken, auth_server: AuthServer, access_token: Option<String>, ) -> Self
Initialize a new set of [Credentials] using a RefreshToken.
Optionally include an access_token, if not included, then one can be requested
with Self::request_access_token.
Sourcepub const fn from_client_credentials(
tokens: ClientCredentials,
auth_server: AuthServer,
access_token: Option<String>,
) -> Self
pub const fn from_client_credentials( tokens: ClientCredentials, auth_server: AuthServer, access_token: Option<String>, ) -> Self
Initialize a new set of [Credentials] using ClientCredentials.
Optionally include an access_token, if not included, then one can be requested
with Self::request_access_token.
Sourcepub const fn from_pkce_flow(
flow: PkceFlow,
auth_server: AuthServer,
access_token: Option<String>,
) -> Self
pub const fn from_pkce_flow( flow: PkceFlow, auth_server: AuthServer, access_token: Option<String>, ) -> Self
Initialize a new set of [Credentials] using PkceFlow.
Optionally include an access_token, if not included, then one can be requested
with Self::request_access_token.
Sourcepub fn access_token(&self) -> Result<&str, TokenError>
pub fn access_token(&self) -> Result<&str, TokenError>
Get the current access token.
This is an unvalidated copy of the access token. Meaning it can become stale, or may
even be already be stale. See Self::validate and Self::request_access_token.
§Errors
TokenError::NoAccessTokenif there is no access token
Sourcepub const fn payload(&self) -> &OAuthGrant
pub const fn payload(&self) -> &OAuthGrant
Get the payload used to request an access token.
Sourcepub async fn request_access_token(&mut self) -> Result<&str, TokenError>
pub async fn request_access_token(&mut self) -> Result<&str, TokenError>
Sourcepub const fn auth_server(&self) -> &AuthServer
pub const fn auth_server(&self) -> &AuthServer
The AuthServer that issues the tokens.
Sourcepub fn validate(&self) -> Result<String, TokenError>
pub fn validate(&self) -> Result<String, TokenError>
Validate the access token, returning it if it is valid, or an error describing why it is invalid.
§Errors
TokenError::NoAccessTokenif an access token has not been requested.TokenError::InvalidAccessTokenif the access token is invalid.
Trait Implementations§
Source§impl Clone for OAuthSession
impl Clone for OAuthSession
Source§fn clone(&self) -> OAuthSession
fn clone(&self) -> OAuthSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OAuthSession
impl Debug for OAuthSession
Source§impl From<OAuthSession> for TokenDispatcher
impl From<OAuthSession> for TokenDispatcher
Source§fn from(value: OAuthSession) -> Self
fn from(value: OAuthSession) -> Self
Source§impl PyClass for OAuthSession
impl PyClass for OAuthSession
Source§impl PyClassImpl for OAuthSession
impl PyClassImpl for OAuthSession
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<OAuthSession>
type ThreadChecker = SendablePyClass<OAuthSession>
type Inventory = Pyo3MethodsInventoryForOAuthSession
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<OAuthSession> for PyClassImplCollector<OAuthSession>
impl PyClassNewTextSignature<OAuthSession> for PyClassImplCollector<OAuthSession>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a OAuthSession
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a OAuthSession
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut OAuthSession
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut OAuthSession
Source§impl PyTypeInfo for OAuthSession
impl PyTypeInfo for OAuthSession
Source§type AsRefTarget = PyCell<OAuthSession>
type AsRefTarget = PyCell<OAuthSession>
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
Source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
object is an instance of this type or a subclass of this type.Source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
object is an instance of this type.Auto Trait Implementations§
impl Freeze for OAuthSession
impl !RefUnwindSafe for OAuthSession
impl Send for OAuthSession
impl Sync for OAuthSession
impl Unpin for OAuthSession
impl !UnwindSafe for OAuthSession
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'a, T> FromPyObject<'a> for T
impl<'a, T> FromPyObject<'a> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);