MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseAuthCodeInput

Function parseAuthCodeInput

cli/src/utils/chatgpt-oauth.ts:226–242  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

224}
225
226function parseAuthCodeInput(input: string): { code: string; state?: string } {
227 const trimmed = input.trim()
228
229 if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
230 const callback = new URL(trimmed)
231 const code = callback.searchParams.get('code')
232 const state = callback.searchParams.get('state') ?? undefined
233
234 if (!code) {
235 throw new Error('No authorization code found in callback URL.')
236 }
237
238 return { code, state }
239 }
240
241 return { code: trimmed }
242}
243
244export async function exchangeChatGptCodeForTokens(
245 authCodeInput: string,

Callers 1

Calls 1

getMethod · 0.65

Tested by

no test coverage detected