swagger-api / swagger-api/swagger-ui

What is the recommended way to swap OAuth2 token with an API token?

Open
#6,286 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat: auth type: question type: support
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: Windows 10
  • Browser: Firefox
  • Version: 79
  • Method of installation: Asp.Net Swashbuckle
  • Swagger-UI version: ?
  • Swagger/OpenAPI version: OpenAPI 3
How can we help?

I need to exchange an Oauth2 token from an STS for an API token provided by my API. This is done by making an API request passing the Oauth2 token and my API returns a new Bearer token that should be specified in API requests. I'm trying to integrate this into Swagger UI. I have configured it to get the Oauth2 token ("implicit" flow) and that's working fine. I'm just not sure what the best way is to then do the token exchange and replace the Bearer token returned from Oauth2 with the API token for all future "Try it Out" requests. What would you suggest for this?

The documentation says that the requestInterceptor should be called for Oauth2 requests and that seems to be the perfect spot, but my requestInterceptor is only getting called for "Try it Out" requests.

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

Start with the Swagger UI documentation for the OAuth2 implicit flow and requestInterceptor, then trace how authorization is applied to Try it Out requests. Verify whether the documented interception point covers OAuth2 requests and establish the supported path for exchanging the token and applying the replacement token to later requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, authentication
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.