Mule 4 HTTP Request Client to access OAuth 2 end point












1















There is an external service (lets say "https://external-service.com/service") which is secured by OAuth2. I have client ID (Lets say "123_my_client_id"), Secret ID ("324_mysecret") and the access token URL ( lets say "https://access-token.com/access-token") which returns me the token.

I want to access this service with my Mule 4 Http Request. I followed this https://docs.mulesoft.com/connectors/http/http-authentication#oauth2-client-credentials, but couldn't find any workable solution.



This can be done in Mule 3.9. but still struggling to set up this http request configuration for Mule 4. Can anyone please help to setup this request config .










share|improve this question























  • "This can be done in Mule 3.9" -> can you please tell me how?

    – imehl
    Feb 19 at 11:31
















1















There is an external service (lets say "https://external-service.com/service") which is secured by OAuth2. I have client ID (Lets say "123_my_client_id"), Secret ID ("324_mysecret") and the access token URL ( lets say "https://access-token.com/access-token") which returns me the token.

I want to access this service with my Mule 4 Http Request. I followed this https://docs.mulesoft.com/connectors/http/http-authentication#oauth2-client-credentials, but couldn't find any workable solution.



This can be done in Mule 3.9. but still struggling to set up this http request configuration for Mule 4. Can anyone please help to setup this request config .










share|improve this question























  • "This can be done in Mule 3.9" -> can you please tell me how?

    – imehl
    Feb 19 at 11:31














1












1








1








There is an external service (lets say "https://external-service.com/service") which is secured by OAuth2. I have client ID (Lets say "123_my_client_id"), Secret ID ("324_mysecret") and the access token URL ( lets say "https://access-token.com/access-token") which returns me the token.

I want to access this service with my Mule 4 Http Request. I followed this https://docs.mulesoft.com/connectors/http/http-authentication#oauth2-client-credentials, but couldn't find any workable solution.



This can be done in Mule 3.9. but still struggling to set up this http request configuration for Mule 4. Can anyone please help to setup this request config .










share|improve this question














There is an external service (lets say "https://external-service.com/service") which is secured by OAuth2. I have client ID (Lets say "123_my_client_id"), Secret ID ("324_mysecret") and the access token URL ( lets say "https://access-token.com/access-token") which returns me the token.

I want to access this service with my Mule 4 Http Request. I followed this https://docs.mulesoft.com/connectors/http/http-authentication#oauth2-client-credentials, but couldn't find any workable solution.



This can be done in Mule 3.9. but still struggling to set up this http request configuration for Mule 4. Can anyone please help to setup this request config .







mule mule-studio mule-esb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 13:51









DéboraDébora

2,2691765134




2,2691765134













  • "This can be done in Mule 3.9" -> can you please tell me how?

    – imehl
    Feb 19 at 11:31



















  • "This can be done in Mule 3.9" -> can you please tell me how?

    – imehl
    Feb 19 at 11:31

















"This can be done in Mule 3.9" -> can you please tell me how?

– imehl
Feb 19 at 11:31





"This can be done in Mule 3.9" -> can you please tell me how?

– imehl
Feb 19 at 11:31












1 Answer
1






active

oldest

votes


















3














In order to migrate the request authentication to Mule 4,the config now belongs in the http:request-connection component and the HTTP authentication configuration must be placed within an http:authentication component. This applies to all authentication types supported: basic, digest, NTLM and OAuth2.



From the example in the link provided:



    <http:request-config name="HTTP_Request_Configuration"
host="some.api.com" port="80" basePath="/api/1.0">
<oauth:client-credentials-grant-type
clientId="your_client_id" clientSecret="your_client_secret"
tokenUrl="http://some.api.com/api/1.0/oauth/token"
scopes="access_user_details, read_user_files">
</oauth:client-credentials-grant-type>
</http:request-config>


Changes to something like:



    <http:request-config name="HTTP_Request_Configuration">
<http:request-connection host="some.api.com" port="80">
<http:authentication>
<oauth:client-credentials-grant-type
clientId="your_client_id" clientSecret="your_client_secret"
tokenUrl="http://some.api.com/api/1.0/oauth/token" scopes="access_user_details, read_user_files" />
</http:authentication>
</http:request-connection>
</http:request-config>


Studio may complain about the oauth element, but it should start up fine. Just ignore it.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007544%2fmule-4-http-request-client-to-access-oauth-2-end-point%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    In order to migrate the request authentication to Mule 4,the config now belongs in the http:request-connection component and the HTTP authentication configuration must be placed within an http:authentication component. This applies to all authentication types supported: basic, digest, NTLM and OAuth2.



    From the example in the link provided:



        <http:request-config name="HTTP_Request_Configuration"
    host="some.api.com" port="80" basePath="/api/1.0">
    <oauth:client-credentials-grant-type
    clientId="your_client_id" clientSecret="your_client_secret"
    tokenUrl="http://some.api.com/api/1.0/oauth/token"
    scopes="access_user_details, read_user_files">
    </oauth:client-credentials-grant-type>
    </http:request-config>


    Changes to something like:



        <http:request-config name="HTTP_Request_Configuration">
    <http:request-connection host="some.api.com" port="80">
    <http:authentication>
    <oauth:client-credentials-grant-type
    clientId="your_client_id" clientSecret="your_client_secret"
    tokenUrl="http://some.api.com/api/1.0/oauth/token" scopes="access_user_details, read_user_files" />
    </http:authentication>
    </http:request-connection>
    </http:request-config>


    Studio may complain about the oauth element, but it should start up fine. Just ignore it.






    share|improve this answer




























      3














      In order to migrate the request authentication to Mule 4,the config now belongs in the http:request-connection component and the HTTP authentication configuration must be placed within an http:authentication component. This applies to all authentication types supported: basic, digest, NTLM and OAuth2.



      From the example in the link provided:



          <http:request-config name="HTTP_Request_Configuration"
      host="some.api.com" port="80" basePath="/api/1.0">
      <oauth:client-credentials-grant-type
      clientId="your_client_id" clientSecret="your_client_secret"
      tokenUrl="http://some.api.com/api/1.0/oauth/token"
      scopes="access_user_details, read_user_files">
      </oauth:client-credentials-grant-type>
      </http:request-config>


      Changes to something like:



          <http:request-config name="HTTP_Request_Configuration">
      <http:request-connection host="some.api.com" port="80">
      <http:authentication>
      <oauth:client-credentials-grant-type
      clientId="your_client_id" clientSecret="your_client_secret"
      tokenUrl="http://some.api.com/api/1.0/oauth/token" scopes="access_user_details, read_user_files" />
      </http:authentication>
      </http:request-connection>
      </http:request-config>


      Studio may complain about the oauth element, but it should start up fine. Just ignore it.






      share|improve this answer


























        3












        3








        3







        In order to migrate the request authentication to Mule 4,the config now belongs in the http:request-connection component and the HTTP authentication configuration must be placed within an http:authentication component. This applies to all authentication types supported: basic, digest, NTLM and OAuth2.



        From the example in the link provided:



            <http:request-config name="HTTP_Request_Configuration"
        host="some.api.com" port="80" basePath="/api/1.0">
        <oauth:client-credentials-grant-type
        clientId="your_client_id" clientSecret="your_client_secret"
        tokenUrl="http://some.api.com/api/1.0/oauth/token"
        scopes="access_user_details, read_user_files">
        </oauth:client-credentials-grant-type>
        </http:request-config>


        Changes to something like:



            <http:request-config name="HTTP_Request_Configuration">
        <http:request-connection host="some.api.com" port="80">
        <http:authentication>
        <oauth:client-credentials-grant-type
        clientId="your_client_id" clientSecret="your_client_secret"
        tokenUrl="http://some.api.com/api/1.0/oauth/token" scopes="access_user_details, read_user_files" />
        </http:authentication>
        </http:request-connection>
        </http:request-config>


        Studio may complain about the oauth element, but it should start up fine. Just ignore it.






        share|improve this answer













        In order to migrate the request authentication to Mule 4,the config now belongs in the http:request-connection component and the HTTP authentication configuration must be placed within an http:authentication component. This applies to all authentication types supported: basic, digest, NTLM and OAuth2.



        From the example in the link provided:



            <http:request-config name="HTTP_Request_Configuration"
        host="some.api.com" port="80" basePath="/api/1.0">
        <oauth:client-credentials-grant-type
        clientId="your_client_id" clientSecret="your_client_secret"
        tokenUrl="http://some.api.com/api/1.0/oauth/token"
        scopes="access_user_details, read_user_files">
        </oauth:client-credentials-grant-type>
        </http:request-config>


        Changes to something like:



            <http:request-config name="HTTP_Request_Configuration">
        <http:request-connection host="some.api.com" port="80">
        <http:authentication>
        <oauth:client-credentials-grant-type
        clientId="your_client_id" clientSecret="your_client_secret"
        tokenUrl="http://some.api.com/api/1.0/oauth/token" scopes="access_user_details, read_user_files" />
        </http:authentication>
        </http:request-connection>
        </http:request-config>


        Studio may complain about the oauth element, but it should start up fine. Just ignore it.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 17:59









        Ryan CarterRyan Carter

        9,09021522




        9,09021522
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007544%2fmule-4-http-request-client-to-access-oauth-2-end-point%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$