pub struct AccountsAuth { /* private fields */ }Expand description
Signs Carbons and Silicons in to Commit at Silicon Accounts, without an app secret.
Implementations§
Source§impl AccountsAuth
impl AccountsAuth
Sourcepub fn new(accounts_url: impl Into<String>) -> Result<Self, Error>
pub fn new(accounts_url: impl Into<String>) -> Result<Self, Error>
Signs in to Commit (commit) at the given Silicon Accounts URL.
Sourcepub fn builder(accounts_url: impl Into<String>) -> AccountsAuthBuilder
pub fn builder(accounts_url: impl Into<String>) -> AccountsAuthBuilder
Starts a builder for the given Silicon Accounts URL.
Sourcepub fn accounts_url(&self) -> &Url
pub fn accounts_url(&self) -> &Url
The Silicon Accounts URL requests go to.
Sourcepub async fn start_device_sign_in(
&self,
scope: Option<&str>,
client_label: Option<&str>,
) -> Result<DeviceAuthorization, Error>
pub async fn start_device_sign_in( &self, scope: Option<&str>, client_label: Option<&str>, ) -> Result<DeviceAuthorization, Error>
POST /v1/device/authorize with Commit’s client_id: starts a Carbon’s sign-in.
Show user_code and verification_uri (or verification_uri_complete), then poll
with AccountsAuth::wait_for_device_sign_in. scope asks for extra details the
Carbon may share (space-separated, e.g. email); client_label names this device in
the Carbon’s sign-in history.
Sourcepub async fn poll_device_sign_in(
&self,
device: &DeviceAuthorization,
) -> Result<DeviceStatus, Error>
pub async fn poll_device_sign_in( &self, device: &DeviceAuthorization, ) -> Result<DeviceStatus, Error>
Polls a device sign-in once.
Sourcepub async fn wait_for_device_sign_in(
&self,
device: &DeviceAuthorization,
on_event: impl FnMut(DeviceEvent<'_>),
) -> Result<SignIn, Error>
pub async fn wait_for_device_sign_in( &self, device: &DeviceAuthorization, on_event: impl FnMut(DeviceEvent<'_>), ) -> Result<SignIn, Error>
Polls a device sign-in until the Carbon approves it, honouring interval, adding
5 seconds after every slow_down, retrying temporary failures, and giving up when
the code expires. A denied sign-in fails with code access_denied, an expired one
with expired_token.
Sourcepub async fn exchange_slt(&self, slt: &str) -> Result<SignIn, Error>
pub async fn exchange_slt(&self, slt: &str) -> Result<SignIn, Error>
Exchanges a Silicon’s short-lived token (slt_…, single use, 2 minutes, minted for
Commit with silicon-accounts login --app commit -q) for Commit’s tokens, with
Commit’s client_id alone. Commit’s sign-in setup has public_client on. The token
is never logged or echoed in errors.
Sourcepub async fn refresh(&self, refresh_token: &str) -> Result<SignIn, Error>
pub async fn refresh(&self, refresh_token: &str) -> Result<SignIn, Error>
Rotates a refresh token with Commit’s client_id alone. The old token stops working
even if this answer is lost, and presenting it again ends the sign-in: store the new
pair before using it, and never run two refreshes of one sign-in at once.
Sourcepub async fn revoke(&self, token: &str) -> Result<Revocation, Error>
pub async fn revoke(&self, token: &str) -> Result<Revocation, Error>
Ends the sign-in behind a refresh token (or access token) at Silicon Accounts
(POST /v1/oauth/revoke with Commit’s client_id). Commit hears
membership.signed_out with reason app_revoked; the account’s other sign-ins stay.
An unknown or already-ended token answers revoked: false with the reason.