Skip to content

Commit fb760e7

Browse files
authored
Merge pull request #44 from fapo85/add-bruno-collaboration
Collaboration with Bruno Integrations
2 parents 34f3d77 + 5e41c46 commit fb760e7

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,51 @@ The server's settings can be adjusted using specified environment variables and
3939
| `EXPIRES_IN_MINUTES` | `--expires-in-minutes` | The expiration time of the JWT tokens in minutes. Defaults to `52560000`. |
4040
| `GRAND_TYPE` | `--grand-type` | The grand type of the JWT tokens. Defaults to `client_credentials`. |
4141
| `EMAIL` | `--email` | The email of the JWT token. Defaults to `[email protected]`. |
42+
43+
# Collaboration with Bruno
44+
45+
46+
Bruno is our favourite request testing tool.
47+
48+
https://docs.usebruno.com/introduction/what-is-bruno
49+
50+
Therefore, an introduction to how the tokens can be integrated into Bruno.
51+
52+
The workflow is as follows Brono will perform a pre-request against the fake-jwt-server before each request and add the token as header to the actual request.
53+
54+
## Script
55+
56+
```javascript
57+
const tokenUrl = 'http://localhost:8008/token';
58+
try {
59+
let resp = await axios({
60+
method: 'POST',
61+
url: tokenUrl,
62+
});
63+
bru.setVar('ACCESS_TOKEN', resp.data.access_token);
64+
} catch (error) {
65+
throw error;
66+
}
67+
```
68+
69+
## Integration
70+
71+
You can make settings for the entire collection.
72+
The script above is stored in this as a pre-request script.
73+
![bruno - collection script](../fake-jwt-server-fapo/media/bruno-collection-script.png)
74+
75+
The token is stored in the variable ACCESS_TOKEN in the script.
76+
77+
This must be added to the requests as a header.
78+
![bruno - collection headers](../fake-jwt-server-fapo/media/bruno-collection-headers.png)
79+
80+
## Non Local Environment
81+
82+
The following script can be used to set the token depending on the environment.
83+
I am not yet fully satisfied with this solution, so I will update the readme when new findings come to light.
84+
```javascript
85+
if (!bru.getEnvName("local")) {
86+
bru.setVar('ACCESS_TOKEN', "");
87+
return
88+
}
89+
```

media/bruno-collection-headers.png

29.6 KB
Loading

media/bruno-collection-script.png

48.8 KB
Loading

0 commit comments

Comments
 (0)