pub struct TokensClient { /* private fields */ }Expand description
Access to the /v1/gate/tokens endpoints.
Obtain via Gate::tokens.
Implementations§
Source§impl TokensClient
impl TokensClient
Sourcepub async fn create(
&self,
params: CreateTokenParams,
) -> Result<AccessToken, Error>
pub async fn create( &self, params: CreateTokenParams, ) -> Result<AccessToken, Error>
Issue a short-lived access token for a subject.
Maps to POST /v1/gate/tokens. The API key is sent in the request body
rather than the Authorization header.
§Example
use nautilus_rs::{Gate, CreateTokenParams};
let gate = Gate::new("vrn_gate_live_sk_…");
let token = gate.tokens().create(CreateTokenParams {
subject: "idn_alice".into(),
scopes: Some(vec!["read:profile".into()]),
ttl_seconds: Some(900),
}).await?;
println!("expires at {}", token.expires_at);Sourcepub async fn introspect(&self, access_token: &str) -> Result<TokenInfo, Error>
pub async fn introspect(&self, access_token: &str) -> Result<TokenInfo, Error>
Validate an access token and retrieve its claims.
Maps to POST /v1/gate/tokens/introspect. Check
TokenInfo::active to determine whether the token is still valid.
§Example
use nautilus_rs::Gate;
let gate = Gate::new("vrn_gate_live_sk_…");
let info = gate.tokens().introspect("eyJ…").await?;
if info.active {
println!("valid token for {}", info.subject);
}Auto Trait Implementations§
impl !RefUnwindSafe for TokensClient
impl !UnwindSafe for TokensClient
impl Freeze for TokensClient
impl Send for TokensClient
impl Sync for TokensClient
impl Unpin for TokensClient
impl UnsafeUnpin for TokensClient
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