pub struct StaticTokenAuth { /* private fields */ }Expand description
Authentication backed by a fixed access token and instance URL.
Once the token expires, requests will start failing with a 401
INVALID_SESSION_ID from Salesforce. This type does not refresh;
pair it with a flow that does (or rebuild the client) to recover.
Implementations§
Source§impl StaticTokenAuth
impl StaticTokenAuth
Sourcepub fn new(
access_token: impl Into<String>,
instance_url: impl Into<String>,
) -> Self
pub fn new( access_token: impl Into<String>, instance_url: impl Into<String>, ) -> Self
Constructs a session from a known token and instance URL.
instance_url is normalized by trimming a trailing slash so that
path concatenation in the client always produces clean URLs.
Static-token auth doesn’t refresh — when the token expires, calls
will surface 401. Use for short-lived scripts, CLI tools, or
tests where you’ve pasted a token from sf org display. For
long-running services prefer JwtAuth or
RefreshTokenAuth.
§Example
use cirrus_auth::{AuthSession, StaticTokenAuth};
use std::sync::Arc;
let auth: Arc<dyn AuthSession> = Arc::new(StaticTokenAuth::new(
"00D...!AQ...",
"https://my-org.my.salesforce.com",
));
assert_eq!(auth.instance_url(), "https://my-org.my.salesforce.com");Trait Implementations§
Source§impl AuthSession for StaticTokenAuth
impl AuthSession for StaticTokenAuth
Source§fn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AuthResult<Cow<'_, str>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AuthResult<Cow<'_, str>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns a valid bearer access token. Implementations may refresh
expired tokens transparently here; that is why the method is
async.Source§fn instance_url(&self) -> &str
fn instance_url(&self) -> &str
Returns the instance URL for REST requests, e.g.
https://my-org.my.salesforce.com. No trailing slash.Source§fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
stale_token: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invalidate<'life0, 'life1, 'async_trait>(
&'life0 self,
stale_token: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Invalidates a cached token that the SDK has determined is no
longer valid (typically because Salesforce returned 401
INVALID_SESSION_ID when it was used). Read moreSource§impl Clone for StaticTokenAuth
impl Clone for StaticTokenAuth
Source§fn clone(&self) -> StaticTokenAuth
fn clone(&self) -> StaticTokenAuth
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StaticTokenAuth
impl RefUnwindSafe for StaticTokenAuth
impl Send for StaticTokenAuth
impl Sync for StaticTokenAuth
impl Unpin for StaticTokenAuth
impl UnsafeUnpin for StaticTokenAuth
impl UnwindSafe for StaticTokenAuth
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
Mutably borrows from an owned value. Read more