MCPcopy Create free account
hub / github.com/Noumena-Network/code / pollOauthCallbackRelay

Function pollOauthCallbackRelay

src/services/oauth/client.ts:224–251  ·  view source on GitHub ↗
(
  relayId: string,
)

Source from the content-addressed store, hash-verified

222}
223
224export async function pollOauthCallbackRelay(
225 relayId: string,
226): Promise<string | null> {
227 try {
228 const response = await axios.post<{
229 authorization_code?: string
230 pending?: boolean
231 }>(
232 getOauthCallbackRelayEndpoint('/oauth/callback-relay/poll'),
233 { relay_id: relayId },
234 {
235 headers: { 'Content-Type': 'application/json' },
236 timeout: 10000,
237 validateStatus: status =>
238 status === 200 || status === 202 || status === 204 || status === 404,
239 },
240 )
241 if (response.status === 202 || response.status === 204 || response.status === 404) {
242 return null
243 }
244 return response.data.authorization_code ?? null
245 } catch (error) {
246 logForDebugging(
247 `OAuth callback relay poll failed: ${error instanceof Error ? error.message : String(error)}`,
248 )
249 throw error
250 }
251}
252
253export async function exchangeCodeForTokens(
254 authorizationCode: string,

Callers

nothing calls this directly

Calls 2

logForDebuggingFunction · 0.50

Tested by

no test coverage detected