MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / withAccessToken

Method withAccessToken

packages/oauth/src/toolkit.ts:318–338  ·  view source on GitHub ↗
(
    providerName: string | undefined,
    options: {
      readonly oauthRef?: KimiOAuthTokenRef | undefined;
      readonly baseUrl?: string | undefined;
    },
    run: (accessToken: string) => Promise<T>,
  )

Source from the content-addressed store, hash-verified

316 }
317
318 private async withAccessToken<T>(
319 providerName: string | undefined,
320 options: {
321 readonly oauthRef?: KimiOAuthTokenRef | undefined;
322 readonly baseUrl?: string | undefined;
323 },
324 run: (accessToken: string) => Promise<T>,
325 ): Promise<T | { readonly kind: 'error'; readonly message: string }> {
326 const name = providerName ?? KIMI_CODE_PROVIDER_NAME;
327 try {
328 const accessToken = await this.ensureFresh(name, {
329 oauthRef: options.oauthRef ?? this.defaultOAuthRef(options.baseUrl),
330 });
331 return await run(accessToken);
332 } catch (error) {
333 return {
334 kind: 'error',
335 message: error instanceof Error ? error.message : String(error),
336 };
337 }
338 }
339
340 async createFeedbackUploadUrl(
341 body: CreateFeedbackUploadUrlBody,

Callers 3

submitFeedbackMethod · 0.95

Calls 3

ensureFreshMethod · 0.95
defaultOAuthRefMethod · 0.95
runFunction · 0.50

Tested by

no test coverage detected