MCPcopy Create free account
hub / github.com/clawshell/clawshell / load

Method load

src/oauth/storage.rs:52–62  ·  view source on GitHub ↗

Load tokens for a provider, returning None if the file doesn't exist.

(&self, provider_id: &str)

Source from the content-addressed store, hash-verified

50
51 /// Load tokens for a provider, returning None if the file doesn't exist.
52 pub fn load(&self, provider_id: &str) -> Result<Option<OAuthTokens>, std::io::Error> {
53 let path = self.token_path(provider_id);
54 if !path.exists() {
55 return Ok(None);
56 }
57 let content = std::fs::read_to_string(&path)?;
58 let tokens: OAuthTokens = serde_json::from_str(&content)
59 .map_err(|e| std::io::Error::other(format!("failed to parse tokens: {e}")))?;
60 debug!(provider = %provider_id, path = %path.display(), "OAuth tokens loaded");
61 Ok(Some(tokens))
62 }
63
64 /// Remove tokens for a provider.
65 pub fn remove(&self, provider_id: &str) -> Result<(), std::io::Error> {

Callers 5

snapshotMethod · 0.80
load_tokensMethod · 0.80
test_save_and_loadFunction · 0.80
test_load_nonexistentFunction · 0.80

Calls 1

token_pathMethod · 0.80

Tested by 3

test_save_and_loadFunction · 0.64
test_load_nonexistentFunction · 0.64