Auth token chaining
Get an access token from a token endpoint and use it for every other request.
authchainingvariables
What it does
Calls the token endpoint with basic auth built from client credentials, stores the access_token from the response in a collection variable, and sets it as the bearer token for the whole collection. The Auth folder is ordered first so the token exists before the other requests run.
portman-config.json
{ "version": 1, "assignVariables": [ { "openApiOperation": "POST::/oauth/token", "collectionVariables": [ { "responseBodyProp": "access_token", "name": "accessToken" } ] } ], "overwrites": [ { "openApiOperation": "POST::/oauth/token", "overwriteRequestSecurity": { "basic": { "username": "{{clientId}}", "password": "{{clientSecret}}" } } } ], "tests": { "contractTests": [ { "openApiOperation": "*::/*", "statusSuccess": { "enabled": true }, "schemaValidation": { "enabled": true } } ] }, "globals": { "securityOverwrites": { "bearer": { "token": "{{accessToken}}" } }, "orderOfFolders": [ "Auth", "Leads", "Companies" ] }}Run it
terminal
$ npx @apideck/portman -l ./openapi.yaml -c ./portman-config.json -b http://localhost:3050 --envFile ./.env -n trueNotes
- Put PORTMAN_CLIENT_ID and PORTMAN_CLIENT_SECRET in .env to get the {{clientId}} and {{clientSecret}} variables.
- Folder names come from your OpenAPI tags, so adjust orderOfFolders to match them.