MCPcopy Create free account
hub / github.com/openai/openai-node / validateHeaders

Method validateHeaders

src/client.ts:565–586  ·  view source on GitHub ↗
(
    { values, nulls }: NullableHeaders,
    schemes: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean } = {
      bearerAuth: true,
      adminAPIKeyAuth: true,
    },
  )

Source from the content-addressed store, hash-verified

563 }
564
565 protected validateHeaders(
566 { values, nulls }: NullableHeaders,
567 schemes: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean } = {
568 bearerAuth: true,
569 adminAPIKeyAuth: true,
570 },
571 ) {
572 if (values.get('authorization') || values.get('api-key')) {
573 return;
574 }
575 if (nulls.has('authorization') || nulls.has('api-key')) {
576 return;
577 }
578
579 if (this._workloadIdentityAuth && schemes.bearerAuth) {
580 return;
581 }
582
583 throw new Error(
584 'Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted',
585 );
586 }
587
588 protected async authHeaders(
589 opts: FinalRequestOptions,

Callers 1

buildHeadersMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected