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

Function runProtectedRequest

src/utils/http.authE2E.test.ts:147–160  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

145})
146
147async function runProtectedRequest(url: string): Promise<{ ok: true }> {
148 return await withOAuth401Retry(async () => {
149 const authHeaders = getAuthHeaders()
150 if (authHeaders.error) {
151 throw new Error(`Failed to get auth headers: ${authHeaders.error}`)
152 }
153 const response = await axios.get<{ ok: true }>(url, {
154 headers: authHeaders.headers,
155 })
156 return response.data
157 }, {
158 also403Revoked: true,
159 })
160}
161
162describe('withOAuth401Retry managed auth end-to-end', () => {
163 it('re-authenticates a protected request after a 401 and succeeds on retry', async () => {

Callers 1

Calls 2

withOAuth401RetryFunction · 0.85
getAuthHeadersFunction · 0.70

Tested by

no test coverage detected