Kong / Kong/insomnia

Access token is not automatically fetched when a request is used in a test

Open
#6,219 6 comments 0 reactions 0 assignees View on GitHub
B-bug S-unverified
Dominant language
TypeScript
Stars
40k
Forks
2.4k
Avg merge
2d 13h
Merged PRs (30d)
61

Description

### Expected Behavior

When a request uses the "Request-> OAuth 2.0 Access Token" to set an Authorization header I expect the test to automatically retrieve the access token.

I see no way to script this from the documentation.

### Actual Behavior

An error occurs on the inso test execution.

`Error: Failed to run the request. This is likely due to missing environment variables that are referenced in the request.`

### Reproduction Steps

1. Create a request which defines an OAuth2 authentication configuration. In insomnia I can use this to fetch an access token.
2. The request then defines an `Authorization` header, with a tag referencing the OAuth2 access token.
3. Create a simple test, which invokes this request and expects a 200 response.
4. Executing the test using `inso run test`

If you disable the `Authorization` header the error disappears, but obviously the test fails with a 401 error.

### Is there an existing issue for this?

- [X] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.

### Additional Information

_No response_

### Insomnia Version

2023.4.0

### What operating system are you using?

Windows

### Operating System Version

Edition Windows 11 Enterprise Version 22H2 Installed on ‎12/‎04/‎2023 OS build 22621.1992 Serial number PW039BQ8 Experience Windows Feature Experience Pack 1000.22644.1000.0

### Installation method

Downloaded from Insomnia.rest

### Last Known Working Insomnia version

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the `inso run test` entry point and trace how the request's OAuth 2.0 access-token tag is resolved during test execution. Done means the reproduced test automatically fetches the token and receives the expected 200 response without missing-environment-variable errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, cli, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.