Error with Bearer token authorization for GPT to access GPT plugin

I have created a GPT and added actions to connect to my GPT Plugin that performs all operations. I use Bearer token, but I am unable to authorize using it. I tired to change prompt and directly instruct to include Bearer token in the header but it also doesn’t work. I tried different approaches with configuring yaml file but they all failed.
I tried these schemes:

securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: Bearer
      in: header

and

securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

How to resolve this issue?

Just checking, have you also added your Bearer token through the UI? Under your action, you’ll need to scroll down on the left panel and add it through the authentication settings.

I think this is what @huwsername is referring to.

1 Like

yes, I have added it. I wonder, if anyone successfully added bearer authentication.


The problem is that client doesn’t produce correct request.

{
  "domain": "my_plugin.com",
  "method": "post",
  "path": "/query",
  "operation": "query_query_post",
  "operation_hash": "7c3dc79b3c01e1802865f8a35266fc7a54759f89",
  "is_consequential": true,
  "params": {
    "queries": [
      {
        "query": "my_query"
      }
    ]
  }
}

It misses part where authorization is added to header

"is_consequential": true,
  "headers": {
    "Authorization": "Bearer my-token"
  },
1 Like

I actually tried Bearer. I used the test button to try it out in preview. It just hanged, so I googled and got here. But when I go ahead and started the normal chat session and specifically asking it to use Actions, it actually did work. I see it hitting my server and able to retrieve the right info.

Has anyone found a solution to this,
I have parsed the spec correctly but, it just can’t pick up the bearer token

openapi: 3.1.0
info:
  title: Aggregate Reports API
  version: 1.0.0
  description: API for retrieving aggregate reports
servers:
  - url: https://api.example.com/v1
    description: API server
paths:
  /reports/aggregate/per-host:
    get:
      operationId: getAggregateReportsPerHost
      summary: Retrieve aggregate reports per host
      description: Get aggregate reports for hosts based on specified criteria
      parameters:
        - name: from
          in: query
          required: true
          schema:
            type: string
            format: date
          description: Start date for the report period (YYYY-MM-DD)
        - name: to
          in: query
          required: true
          schema:
            type: string
            format: date
          description: End date for the report period (YYYY-MM-DD)
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - failed
              - passed
          description: Filter reports by status
        - name: perPage
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            default: 10
          description: Number of items per page
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number for pagination
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AggregateReportResponse"
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  schemas:
    AggregateReportResponse:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: "#/components/schemas/AggregateReportItem"
        total:
          type: integer
          description: Total number of items
        page:
          type: integer
          description: Current page number
        perPage:
          type: integer
          description: Number of items per page
    AggregateReportItem:
      type: object
      properties:
        hostname:
          type: string
        status:
          type: string
          enum:
            - failed
            - passed
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
        code:
          type: integer

I have worked with API keys before in GPt and it works fine but the bearer token seems to be an issue