pub struct JwtAuth { /* private fields */ }Expand description
JWT Bearer flow auth session.
Construct via JwtAuth::builder.
Implementations§
Source§impl JwtAuth
impl JwtAuth
Sourcepub fn builder() -> JwtAuthBuilder
pub fn builder() -> JwtAuthBuilder
Begins constructing a JwtAuth.
JWT bearer flow (RFC 7523): the SDK signs a JWT assertion with your connected app’s private key and exchanges it for an access token at the configured login URL. Cached access tokens are refreshed transparently on 401.
§Example
use cirrus_auth::JwtAuth;
use std::sync::Arc;
let auth = JwtAuth::builder()
.consumer_key("3MVG9...")
.username("integration-user@example.com")
.login_url("https://login.salesforce.com")
.instance_url("https://my-org.my.salesforce.com")
.private_key_pem_file("./private.pem")?
.build()?;
// Wrap as Arc<dyn AuthSession> and hand to a Cirrus client.
let _shared = Arc::new(auth);Trait Implementations§
Source§impl AuthSession for JwtAuth
impl AuthSession for JwtAuth
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 moreAuto Trait Implementations§
impl !Freeze for JwtAuth
impl !RefUnwindSafe for JwtAuth
impl Send for JwtAuth
impl Sync for JwtAuth
impl Unpin for JwtAuth
impl UnsafeUnpin for JwtAuth
impl !UnwindSafe for JwtAuth
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