Skip to main content

CredentialSource

Trait CredentialSource 

Source
pub trait CredentialSource:
    Debug
    + Send
    + Sync {
    // Required method
    fn reload(&self) -> Option<UserAccessToken>;
}
Expand description

Where a client can go to find out that the stored credential changed under it.

§Why a long-running client needs this

A daemon reads the store once, at startup, and holds the result for as long as it runs. That was invisible while the only way to change the store was to stop the daemon — but auth login does not stop anything, so a host whose credential died before its daemon started stays dead through every sign-in meant to fix it. The operator does the right thing, watches it not work, and has nothing to tell them why.

Watched on 2026-08-29: a Windows daemon started at 04:08Z holding an already-expired token, a sign-in at 10:43Z that wrote a good pair, and 180 unauthorized events an hour for 28 hours without a single minute’s pause across the sign-in. See docs/spikes/token-expiry-and-renewal.md.

§Why it is not a file watch

This is consulted on 401 and nowhere else, so a store that never changes costs nothing and a daemon that is working never reads the disk. It also covers the case a watch would miss on macOS, where the credential lives in a keychain rather than at a path.

Required Methods§

Source

fn reload(&self) -> Option<UserAccessToken>

The credential the store holds now, or None if it cannot be read.

Infallible by design: every failure — missing, unreadable, corrupt — means the same thing to the caller, which is that there is nothing new to try and the 401 stands.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§