feat: OAuth2 - automatically handle Bearer token type only

According to RFC6749 Section 7.1, The client MUST NOT use an access token
if it does not understand the token type.
At this point bruno only understands 'bearer' token_type.
This commit is contained in:
Mateusz Pietryga
2024-05-05 23:47:52 +02:00
parent d982e35a17
commit 2064cc88ab

View File

@@ -284,7 +284,13 @@ const configureRequest = async (
}
request.credentials = credentials;
request.authRequestResponse = response;
request.headers['Authorization'] = `Bearer ${credentials.access_token}`;
// Bruno can handle bearer token type automatically.
// Other - more exotic token types are not touched
// Users are free to use pre-request script and operate on req.credentials.access_token variable
if (credentials?.token_type.toLowerCase() === 'bearer') {
request.headers['Authorization'] = `Bearer ${credentials.access_token}`;
}
}
if (request.awsv4config) {