Adding a custom token header

Created on 24 July 2024, 4 months ago

I seem to be having a devil of a time adding a custom header to the request.

Let's call the header PRIVATE-TOKEN.

My service description is:

operations:
  GetTheThing:
    httpMethod: "GET"
    uri: "part1/{id}/part2/{id2}/part3"
    summary: "Get The Thing"
    parameters:
      id:
        location: "uri"
        required: true
        type: "integer"
      id2:
        location: "uri"
        required: true
        type: "integer"
      "PRIVATE-TOKEN":
        location: "header"
        type: "string"
    responseClass: "getTheThingResponse"

... etc

In a Parameters class I define the local name of the token to be the API's name:
const PROJECT_ACCESS_TOKEN = 'PRIVATE-TOKEN';

In my extension of HttpRequestBase, I retrieve the argument:

public function getArgs(): array {
    return [
      // other params
      Param::PROJECT_ACCESS_TOKEN => myFuncThatGetsEnv(),
    ];
  }

I can debug here and see that the arg is correct.

In the class that extends HttpServiceWrapper base, Ireturn $this->callByRequest($request);.

This all finally makes it into the guzzle client, where I can see my token in the args. But it doesn't seem to get into the header, so my request never authenticates. And actually debugging directly to examine the final, real request that's being sent isn't trivial.

Am I doing something fundamentally wrong here?

πŸ’¬ Support request
Status

Closed: won't fix

Version

10.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States datawench

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024