Many APIs secured with OAuth requires additional parameters to generate a Token. In addition to username/password or client/secret, some APIs may require extra parameter. Like the case of Azure's Resource Manager API, which requires an additional "resource" parameter. Currently, the HTTP Connector does not support this. But there is an alternative solution that can be implemented to bypass this limitation.
These additional parameters should be passed inside the message to be sent by the HTTP Requester. In a normal request (that does not require additional parameters) this would be done using only one HTTP Requester. We are going to separate this into two HTTP Requester:
1.- One to retrieve the Auth Token.
2.- One to access the protected resource using the token generated before.
Although the solution is the same, there are slightly differences between Mule 3 and Mule 4, on how to achieve this:
curl -X GET \ http://localhost:8081/test-token \ -H 'Postman-Token: 640f2ccb-4626-4529-b7da-b9c2ff3fd416' \ -H 'cache-control: no-cache'
1.- A HTTP Requester to retrieve the Auth Token that sends in the message the multi-parts received in the listener.
2.- Transform Message to store in a variable (auth) the Authentication header.
3.- A second HTTP Requester calling the API
Example request:
curl -X GET \ http://0.0.0.0:8081/test-token \ -H 'Postman-Token: f0793c97-05ca-4d6c-8916-6f8b77387cdf' \ -H 'cache-control: no-cache' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F client_id=80cb23ed-0d55-4cd2-7628f6e407f6 \ -F client_secret=YBm/aHAaQkJ3o/0CS3r4SHctcOrojUE9JVbGos= \ -F grant_type=client_credentials \ -F resource=https://graph.microsoft.com
Check the projects attached to review the full configuration of this examples.
NOTE: client_id, client_secret are not valid values, they were just written to mock the example.
001114526

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.