mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-09 20:57:44 +00:00
1.3 KiB
1.3 KiB
Change OAuth2 token URL
Use a custom decorator to change the OAuth credentials flow token URL.
Estimated time: 20 minutes
Step-by-step instructions
-
Add this code to your repo with the API (the
.redocly.yamlconfirm is an example).plugins: lint: extends: - recommended plugins: - './plugins/acme-plugin.js' decorators: acme/change-token-urls: errorconst ChangeTokenUrl = require('./decorators/change-token-url'); const id = 'acme'; /** @type {import('@redocly/openapi-cli').CustomRulesConfig} */ const decorators = { oas3: { 'change-token-url': ChangeTokenUrl, }, }; module.exports = { id, decorators, };module.exports = ChangeTokenUrl; /** @type {import('@redocly/openapi-cli').OasDecorator} */ function ChangeTokenUrl() { return { SecuritySchemeFlows: { leave(flows, ctx) { if ('TOKEN_URL' in process.env && flows?.clientCredentials) { flows.clientCredentials.tokenUrl = process.env.TOKEN_URL; } } } } };
