Dynamic Token Authentication
Welcome to the Dynamic Token Authentication documentation!
Most modern APIs require some form of authentication, typically a JWT or Bearer token obtained from a /login endpoint. Because Rumour uses a deterministic execution graph, it is trivial to create a workflow where a login request runs first, extracts the token, and passes it to all subsequent requests.
The Workflow Setup
Let's build a simple 2-step workflow.
First, initialize a workspace and scaffold a collection:
rumour init auth_examples
cd auth_examples
rumour new auth_flow -y
1. The Environment
Create a workspace.env.toml to hold the credentials securely.
base_url = "http://localhost:4000/api/v2"
user_email = "user@test.com"
user_pass = "pass123"
2. The Login Node
Create 1_login.toml. This request sends the credentials and uses the [extract] block to pull the access_token from the JSON response and store it in global memory.
name = "Authenticate User"
[request]
method = "POST"
url = "{{base_url}}/auth/login"
[body]
type = "json"
raw = '{"email": "{{user_email}}", "password": "{{user_pass}}"}'
[extract]
# This pulls the value of 'token' from the response JSON body
auth_token = "token"
[assert]
status = 200
3. The Protected Node
Create 2_get_profile.toml. This request explicitly lists 1_login.toml as a dependency, ensuring Rumour waits for the login to succeed. It then injects {{auth_token}} into the Authorization header.
name = "Fetch Secure Profile"
[dependencies]
# We require the auth_token exported by the login node
"1_login.toml" = "auth_token"
[request]
method = "GET"
url = "{{base_url}}/users/profile"
[headers]
Authorization = "Bearer {{auth_token}}"
[assert]
status = 200
Execution & Output Trace
When you run this directory, Rumour analyzes the [dependencies] block, builds a DAG, and correctly runs the login before the profile request.
rumour run ./auth_flow/ -v
The Trace
POST http://localhost:4000/api/v2/auth/login
URL: http://localhost:4000/api/v2/auth/login
Body (json): {"email": "user@test.com", "password": "pass123"}
✓ SUCCESS: ./1_login.toml (6ms)
GET http://localhost:4000/api/v2/users/profile
Header: Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
URL: http://localhost:4000/api/v2/users/profile
✓ SUCCESS: ./2_profile.toml (4ms)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 2 │
│ Successful: 2 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 28ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- ./1_login.toml [200] [15ms]
- ./2_profile.toml [200] [12ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
Validating the Extraction
If you want to verify that the token was extracted correctly without looking at the raw terminal trace, you can run the suite with the --vars diagnostic flag.
rumour run ./auth_flow/ --vars
In the output, you will see the variable stored in memory at runtime:
RUNTIME VARIABLES:
./1_login.toml.1_login.accessToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
./1_login.toml.1_login.auth_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
./1_login.toml.1_login.id = 1
./1_login.toml.accessToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
./1_login.toml.auth_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
./1_login.toml.id = 1
./2_profile.toml.2_profile.id = 1
./2_profile.toml.id = 1
1_login.accessToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
1_login.auth_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
1_login.id = 1
2_profile.id = 1
accessToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
user_email = user@test.com
user_pass = pass123
auth_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAdGVzdC5jb20iLCJyb2xlIjoidXNlciIsImlkIjoxLCJpYXQiOjE3ODgyNDA4MzcsImV4cCI6MTc4ODI0NDQzN30.67VCVJEjaheWRSYEckL6Ogp0hkeekrbi9BttUh0GQaw
base_url = http://localhost:4000/api/v2
id = 1