Current issue
When configuring an OAS 3.0 spec and setting the security scheme to OAuth 2 the authentication doesn't work and get an invalid redirect_uri (oauth2-redirect.html).
The Authorization code flow can't be implemented.
Desired state
It should be possible to configure any OAuth flows in the Active Docs of the Developer portal.
More context
There is a KCS that explains how to configure flows requiring a redirect URL. The current workaround is to create a page through CMS with the contents provided by swagger-ui - https://raw.githubusercontent.com/swagger-api/swagger-ui/refs/tags/v5.12.3/dist/oauth2-redirect.html and configure this page as a valid redirect URL on the auth provider.
For QE and (potentially) Docs
The implementation in the PR does the following:
- Adds /oauth2-redirect.hml globally to all portals, the content of the file is taken from https://raw.githubusercontent.com/swagger-api/swagger-ui/refs/tags/v5.12.3/dist/oauth2-redirect.html
- Adds the following snippet to the the template of /docs page in the default dev portal:
const url = "{{spec.url}}"; const serviceEndpoint = "{{spec.api_product_production_public_base_url}}" const oauth2RedirectUrl = window.location.origin + "/oauth2-redirect.html" SwaggerUI({ url: url, dom_id: "#swagger-ui-container", oauth2RedirectUrl: oauth2RedirectUrl }, serviceEndpoint);
It only applies to the *new* portal, existing customers who want to use the feature, would need to update their templates manually (the abovementioned KCS would still work as guidance, I believe).
CAVEATS:
1. the redirection doesn't work on the admin portal despite being able to "preview" the rendered spec
2. in the developer portal, the Draft/Published sidebar on the right needs to be closed, as otherwise the window.location.origin does not work right because of using frames