
What Auto-Auth Does
Backend APIs almost always sit behind some form of token-based auth — an OAuthBearer, an AWS Cognito access token, a custom session cookie. Tokens expire. When they do, every test in the run fails until someone pastes a fresh value into the credentials form.
Auto-Auth removes the manual rotation. You configure your project’s login flow once. Before every test run TestSprite obtains a fresh token and uses it across every backend test in the run.
When to Use This
- Your API uses bearer tokens, session cookies, or OAuth refresh flows that expire on a schedule (most modern APIs)
- You’re tired of pasting credentials before every scheduled run, or your nightly schedule keeps breaking on Monday morning because Friday’s token expired
- You want scheduled reruns to run cleanly without human attendance
sk_live_…), you don’t need Auto-Auth — Static Credentials cover that case fine. See Static Credentials at the bottom.
Prerequisites
- A Starter or Standard subscription (Auto-Auth is a Pro feature). Free-plan projects see a paywall card with an Upgrade CTA where the configuration would normally appear.
- A backend project with at least one API under test
- Login credentials your API accepts (username/password, OAuth client credentials + refresh token, or AWS Cognito refresh token)
Subscription Plans
Quick Start
Open the Authentication tab

Click Configure

Fill in the fields and Test Login

Save

Choosing a Method
The configuration modal offers three methods. Pick the one that matches your API.
AWS Cognito

What it does
TestSprite uses your stored Cognito refresh token to obtain a fresh access token before each test run. The access token is then attached to your test requests.Fields
How to obtain a refresh token
A refresh token is issued when a user successfully signs in. The simplest way to capture one for testing:Open your app's sign-in page in a browser
Open DevTools → Application → Local Storage / Cookies
CognitoIdentityServiceProvider.<clientId>.<username>.refreshToken. The value is the refresh token string.Copy the refresh token into the Auto-Auth form
30-day expiry warning
AWS Cognito refresh tokens are capped at 30 days from issue by default (this can be configured per app client in AWS, but 30 is the AWS default). When your stored refresh token gets close to expiry, the Authentication tab surfaces a yellow warning badge:OAuth Refresh (Beta)

What it does
TestSprite uses your OAuth provider’s standard refresh-token grant to obtain a fresh access token before each test run, and reads the access token out of your provider’s response.Fields
Where to get a refresh token
Each provider’s flow is different. The most common path:- Register a new “OAuth app” in your provider’s console (Google Cloud Console, Auth0 Dashboard, Okta Admin)
- Set the redirect URI to something local like
http://localhost:1234/callback - Use the provider’s playground or a small script to walk through the authorization-code flow once and capture the refresh token
Username / Password

What it does
TestSprite calls the login endpoint you specify with your username and password, and reads the token out of the JSON response using the path you provide.Fields
Body template tips
{{username}} and {{password}} are placeholders that get filled in with your stored credentials. You can shape the body however your API needs:
Token Injection
Once TestSprite has the token, it has to attach it to your test requests in the right way. The Inject As field at the bottom of the modal controls this.
X-Auth-Token) or cookie name (e.g. session).
Test Login: Verify Before You Rely
The Test Login button at the bottom of the modal runs a single end-to-end refresh against your config and shows you exactly what came back.
Health States on the Authentication Tab
Once configured, the Auto-refresh card shows one of five states. Knowing what each means saves debugging time. The card always shows a green Pro · Unlocked badge on Pro plans; the state badge sits next to it.Verified · Xm ago
Verified · Xm ago
Pending verification
Pending verification
Failing
Failing
Configured but disabled
Configured but disabled
Not configured
Not configured
Day-2 Operations
Edit a saved config
Click Edit on the card. The modal opens with all non-secret fields pre-populated. Secret fields (password, client secret, refresh token) show•••••••• as a placeholder and are preserved if you leave them blank. Type a new value to overwrite.

Temporarily disable
Flip the toggle on the card off. The config stays saved; new test runs skip Auto-Auth and fall back to your Static Credentials (if any). Flip back on — TestSprite verifies the config still works before re-enabling.
Delete a config
Use Edit → clear all fields → Save. Or contact support if you want a hard delete.Security
- Encrypted at rest: secrets (password, client secret, refresh token) are stored encrypted.
- Never echoed back to the browser: saved secrets render as
••••••••placeholders in the form. Leaving the field blank keeps the stored value. - Server-side only: Test Login and the actual token refresh both run on the server. Your secrets never traverse the browser-to-API path.
- No credential logging: full request bodies are not logged.
If You Can’t Use Auto-Auth: Static Credentials
If Auto-Auth’s three methods don’t fit your API — for example, you have a long-lived API key that never expires, or your auth flow requires a hardware token, or you’re on the Free plan and don’t want to upgrade — you can still run backend tests by pasting credentials manually.
- Paste a token, API key, or session string per API family (Users, Orders, Payments, etc.)
- Apply the same value to multiple APIs sharing an auth type via the All
<auth-type>· N APIs bulk-update buttons (e.g. “All Bearer · 3 APIs”) - Rotate (overwrite) without removing the test cases that use them

Comparing Static Credentials vs Auto-Auth
Troubleshooting
Test Login says 'auth' failure but my credentials are correct
Test Login says 'auth' failure but my credentials are correct
- Refresh token has expired or been revoked. AWS Cognito caps at 30 days; OAuth providers revoke on password change, app uninstall, or admin action. Capture a fresh refresh token and update the field.
- Client ID / client secret mismatch. Double-check you copied them from the right OAuth app — different environments (dev/prod) have different client IDs.
- Account is disabled or locked. Try signing in to your app with the test user’s credentials in a browser; if the manual sign-in fails, fix that first.
Test Login says 'parse' failure
Test Login says 'parse' failure
- Default
$.access_tokenworks for AWS Cognito, Auth0, Okta, Google, most standards-compliant providers - If your response shape is
{"data":{"jwt":"…"}}, set token path to$.data.jwt - If your response shape is
{"token":"…"}, set token path to$.token - Use the failing response body in the error toast as your reference
Test Login succeeds but real test runs return 401
Test Login succeeds but real test runs return 401
- Check the Inject As picker: try Bearer first; if that fails, try Custom Header with the header name your API documentation specifies (e.g.
X-Auth-Token); if that fails, try Cookie - For Cookie injection, the cookie name field expects just the name (e.g.
session), notCookie: session=…
The Pro · Unlocked badge is gone after I enabled the toggle, and the card now says 'Failing'
The Pro · Unlocked badge is gone after I enabled the toggle, and the card now says 'Failing'
My API uses a custom token header AND requires a custom Content-Type
My API uses a custom token header AND requires a custom Content-Type
What if my CI/CD rotates the test user's password regularly?
What if my CI/CD rotates the test user's password regularly?