swagger-api / swagger-api/swagger-ui

Unable to get preauthorize to work

Open
#8,348 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: macOS
  • Browser: chrome
  • Version: latest
  • Method of installation: downloaded from github release page
  • Swagger-UI version: 4.15.5
  • Swagger/OpenAPI version: Swagger 2.0
Content & configuration

I need to have all the APIs to include Authorization header as part of the call. Setting preauthorizeApiKey does not appears to be working in the v4.15.5. I tried to put this line inside the onComplete function, but still does not work. I am not using any npm package. This is directly using the dist/ standalone mentioned here.

Swagger/OpenAPI definition:
Unrelated

Swagger-UI configuration options:

  window.ui = SwaggerUIBundle({
    url: "./api.swagger.json",
    dom_id: '#swagger-ui',
    deepLinking: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout",
    onComplete: () => {
      ui.preauthorizeApiKey("key", "value");
    }
  });
Screenshots
image
How can we help?

I am not sure if this is a bug or not. I cannot get the Authorization header set.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the Swagger UI 4.15.5 dist/ standalone build and the shown onComplete call to preauthorizeApiKey. Inspect the preauthorization flow and verify whether the resulting API requests include the Authorization header. Done means the standalone configuration reliably applies the key to API calls, or the issue is documented as expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.