pub struct AuthProvider { /* private fields */ }Expand description
Resolves and caches a GitHub personal access token from multiple sources.
Implementations§
Source§impl AuthProvider
impl AuthProvider
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an AuthProvider, eagerly attempting token resolution.
Does not fail if no token is available — some deployments may not
need remote sync. Call Self::resolve_token when a token is required.
Sourcepub fn resolve_token(&self) -> Result<SecretString, MemoryError>
pub fn resolve_token(&self) -> Result<SecretString, MemoryError>
Resolve a GitHub personal access token, returning it wrapped in
SecretString so it cannot accidentally appear in logs or error chains.
Checks (in order):
MEMORY_MCP_GITHUB_TOKENenv var~/.config/memory-mcp/tokenfile- System keyring (GNOME Keyring / KWallet / macOS Keychain)
Sourcepub fn resolve_with_source(
&self,
) -> Result<(SecretString, TokenSource), MemoryError>
pub fn resolve_with_source( &self, ) -> Result<(SecretString, TokenSource), MemoryError>
Resolve the token and return which source provided it.
Like resolve_token, returns the cached token if
one was resolved at startup. Falls back to the resolution chain
(env var → file → keyring) if no cached token exists.
Source§impl AuthProvider
impl AuthProvider
Sourcepub fn with_token(token: &str) -> Self
pub fn with_token(token: &str) -> Self
Create an AuthProvider with a pre-set token.
Use this when you already have a token from your own auth flow and want to skip the built-in resolution chain (env var → file → keyring).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthProvider
impl RefUnwindSafe for AuthProvider
impl Send for AuthProvider
impl Sync for AuthProvider
impl Unpin for AuthProvider
impl UnsafeUnpin for AuthProvider
impl UnwindSafe for AuthProvider
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more