https://github.com/jd297/insomnia-plugin-jd297-api-token-auto-refresh
Insomnia plugin that checks for an api token in response and saves it as a template variable.
https://github.com/jd297/insomnia-plugin-jd297-api-token-auto-refresh
insomnia insomnia-plugin
Last synced: 6 months ago
JSON representation
Insomnia plugin that checks for an api token in response and saves it as a template variable.
- Host: GitHub
- URL: https://github.com/jd297/insomnia-plugin-jd297-api-token-auto-refresh
- Owner: JD297
- License: bsd-2-clause
- Created: 2022-11-26T23:56:59.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-28T19:34:52.000Z (almost 3 years ago)
- Last Synced: 2025-02-13T20:48:59.015Z (8 months ago)
- Topics: insomnia, insomnia-plugin
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# insomnia-plugin-jd297-api-token-auto-refresh
Insomnia plugin that checks for an api token in response and saves it as a template variable.
#### Manual Installation
1. Download "insomnia-plugin-jd297-api-token-auto-refresh-{version}.zip" from [Releases > Assets](https://github.com/JD297/insomnia-plugin-jd297-api-token-auto-refresh/releases)
2. Go to Application > Preferences > Plugins
3. Click "Reveal Plugins Folder"
4. Extract the ZIP file from step 1 to the "plugins" folder
5. Click "Reload Plugins"#### Manual Configuration
Update your [environment](https://docs.insomnia.rest/insomnia/environment-variables/):
1. Click "Manage Environments"
2. Create a "jd297-api-token-auto-refresh" environment variable with the response key you need:Default
```json
{
"jd297-api-token-auto-refresh": {
"api_token_response_key": "token"
}
}
```Example
```json
{
"jd297-api-token-auto-refresh": {
"api_token_response_key": "access_token"
}
}
```#### Automatic token refresh
Create a request for an auth route. E.g.:
```json
POST http://localhost:8000/api/oauth/token
{
"grant_type": "client_credentials",
"client_id": "...",
"client_secret": "..."
}
```The Plugin now looks for the "api_token_response_key" from our environment config in the response. If found the plugin
saves the data to a [Template Tag](https://docs.insomnia.rest/insomnia/template-tags).
If the token is not valid any more just send the auth request again and the Template Tag will be refreshed everywhere you used it.#### Template Tag
Now create a [Bearer Token](https://docs.insomnia.rest/insomnia/authentication#bearer-token) authentication.
In the token field you can pass the Template Tag "jd297ApiTokenAutoRefreshApiToken".* [Insomnia Plugins](https://docs.insomnia.rest/insomnia/introduction-to-plugins)
* [The Insomnia Plugin Hub](https://insomnia.rest/plugins)