httpyac
httpyac copied to clipboard
Setting `oauth2_interceptRequest` if not already defined
I have a common.http
file that I import before every request. The script in this file sets the oauth2_interceptRequest
to disable SSL verification:
exports.oauth2_interceptRequest = function(request, context) {
request.options = { https: { rejectUnauthorized: false }};
};
Unfortunately, it seems that assigning to the oauth2_*
variables invalides any access token obtained for the oauth2 prefix, and thus a new access token is retrieved for every request.
Note that I implement a OAuth2 Password Grant type returning an access token with a lifetime in hours, and there is no refresh token. Accordingly oauth2_keepAlive
is not set.
Of course exports
is empty when the common.http
file is run, so I can't test that. Wrapping the above code in if (typeof oauth2_interceptRequest === undefined)
does not seem to work.
What can I do?