DevTools

OAuth Client Credentials

This template exchanges client credentials for an OAuth access token and uses that token to call a protected API. Ideal for service-to-service integrations and headless CI checks.

Required env vars

How to run it

devtools flow run oauth-client-creds.yaml
TODO:
# oauth-client-creds.yaml
version: 1
name: OAuth CC flow
env:
  TOKEN_URL: https://auth.example.com/oauth/token
  CLIENT_ID: {{#env:CLIENT_ID}}
  CLIENT_SECRET: {{#env:CLIENT_SECRET}}

requests:
  - id: get_token
    method: POST
    url: {{ env.TOKEN_URL }}
    headers:
      Content-Type: application/x-www-form-urlencoded
    body:
      form:
        grant_type: client_credentials
        client_id: {{ env.CLIENT_ID }}
        client_secret: {{ env.CLIENT_SECRET }}
    expect:
      - status: 200

  - id: list_accounts
    method: GET
    url: https://api.example.com/accounts
    headers:
      Authorization: Bearer {{ get_token.response.body.access_token }}
    expect:
      - status: 200

What to change

Common variations

Links