MCPcopy
hub / github.com/21st-dev/1code / getToken

Method getToken

src/main/lib/credential-manager.ts:175–186  ·  view source on GitHub ↗

* Get token value for a source (convenience method) * Returns null if no credential exists or if expired

(source: LoadedSource)

Source from the content-addressed store, hash-verified

173 * Returns null if no credential exists or if expired
174 */
175 async getToken(source: LoadedSource): Promise<string | null> {
176 const cred = await this.load(source);
177 if (!cred?.value) return null;
178
179 // Check expiry
180 if (this.isExpired(cred)) {
181 debug(`[SourceCredentialManager] Token expired for ${source.config.slug}`);
182 return null;
183 }
184
185 return cred.value;
186 }
187
188 /**
189 * Get API credential for a source (handles basic auth JSON parsing)

Callers 1

hasValidCredentialsMethod · 0.95

Calls 2

loadMethod · 0.95
isExpiredMethod · 0.95

Tested by

no test coverage detected