How to use proxies with authentication in my HTTP requests?












6















I have a proxy IP Address (that also require a username and password). When i try using them to visit webpages, i get "Proxy Authentication Required".



I'm found this other Stackoverflow post from 2016, and this Github Issue that was closed, but they don't provide anything useful:




  • Proxy golang https

  • https://github.com/golang/go/issues/22288


Any suggestions?



EDIT:
Saw this post: Setting up proxy for HTTP client



It's kinda close. However, for some urls I'm able to get a successful response using my proxy, but for certain urls, I get a "Proxy Authorization Required".










share|improve this question

























  • Possible duplicate of Setting up proxy for HTTP client

    – danicheeta
    Nov 21 '18 at 7:34
















6















I have a proxy IP Address (that also require a username and password). When i try using them to visit webpages, i get "Proxy Authentication Required".



I'm found this other Stackoverflow post from 2016, and this Github Issue that was closed, but they don't provide anything useful:




  • Proxy golang https

  • https://github.com/golang/go/issues/22288


Any suggestions?



EDIT:
Saw this post: Setting up proxy for HTTP client



It's kinda close. However, for some urls I'm able to get a successful response using my proxy, but for certain urls, I get a "Proxy Authorization Required".










share|improve this question

























  • Possible duplicate of Setting up proxy for HTTP client

    – danicheeta
    Nov 21 '18 at 7:34














6












6








6


2






I have a proxy IP Address (that also require a username and password). When i try using them to visit webpages, i get "Proxy Authentication Required".



I'm found this other Stackoverflow post from 2016, and this Github Issue that was closed, but they don't provide anything useful:




  • Proxy golang https

  • https://github.com/golang/go/issues/22288


Any suggestions?



EDIT:
Saw this post: Setting up proxy for HTTP client



It's kinda close. However, for some urls I'm able to get a successful response using my proxy, but for certain urls, I get a "Proxy Authorization Required".










share|improve this question
















I have a proxy IP Address (that also require a username and password). When i try using them to visit webpages, i get "Proxy Authentication Required".



I'm found this other Stackoverflow post from 2016, and this Github Issue that was closed, but they don't provide anything useful:




  • Proxy golang https

  • https://github.com/golang/go/issues/22288


Any suggestions?



EDIT:
Saw this post: Setting up proxy for HTTP client



It's kinda close. However, for some urls I'm able to get a successful response using my proxy, but for certain urls, I get a "Proxy Authorization Required".







go proxy get request






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 21:27







Matthew Chan

















asked Nov 21 '18 at 7:06









Matthew ChanMatthew Chan

1,11641738




1,11641738













  • Possible duplicate of Setting up proxy for HTTP client

    – danicheeta
    Nov 21 '18 at 7:34



















  • Possible duplicate of Setting up proxy for HTTP client

    – danicheeta
    Nov 21 '18 at 7:34

















Possible duplicate of Setting up proxy for HTTP client

– danicheeta
Nov 21 '18 at 7:34





Possible duplicate of Setting up proxy for HTTP client

– danicheeta
Nov 21 '18 at 7:34












2 Answers
2






active

oldest

votes


















9














If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.



auth := "username:password"
basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
transport.ProxyConnectHeader = http.Header{}
transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)





share|improve this answer
























  • awesome, this actually worked!!

    – Matthew Chan
    Nov 21 '18 at 7:23






  • 1





    If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

    – Juan
    Nov 21 '18 at 19:07





















0














to add authorization, you may need to add a header:



auth := "{user}:{password}"
basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
request.Header.Add("Proxy-Authorization", basicAuth)





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%2f53406874%2fhow-to-use-proxies-with-authentication-in-my-http-requests%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    9














    If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.



    auth := "username:password"
    basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
    transport.ProxyConnectHeader = http.Header{}
    transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)





    share|improve this answer
























    • awesome, this actually worked!!

      – Matthew Chan
      Nov 21 '18 at 7:23






    • 1





      If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

      – Juan
      Nov 21 '18 at 19:07


















    9














    If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.



    auth := "username:password"
    basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
    transport.ProxyConnectHeader = http.Header{}
    transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)





    share|improve this answer
























    • awesome, this actually worked!!

      – Matthew Chan
      Nov 21 '18 at 7:23






    • 1





      If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

      – Juan
      Nov 21 '18 at 19:07
















    9












    9








    9







    If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.



    auth := "username:password"
    basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
    transport.ProxyConnectHeader = http.Header{}
    transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)





    share|improve this answer













    If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.



    auth := "username:password"
    basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
    transport.ProxyConnectHeader = http.Header{}
    transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 7:18









    JuanJuan

    1063




    1063













    • awesome, this actually worked!!

      – Matthew Chan
      Nov 21 '18 at 7:23






    • 1





      If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

      – Juan
      Nov 21 '18 at 19:07





















    • awesome, this actually worked!!

      – Matthew Chan
      Nov 21 '18 at 7:23






    • 1





      If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

      – Juan
      Nov 21 '18 at 19:07



















    awesome, this actually worked!!

    – Matthew Chan
    Nov 21 '18 at 7:23





    awesome, this actually worked!!

    – Matthew Chan
    Nov 21 '18 at 7:23




    1




    1





    If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

    – Juan
    Nov 21 '18 at 19:07







    If there are other headers required by the request, such as Content-Type or Accept, you should also add them to the ProxyConnectHeader.

    – Juan
    Nov 21 '18 at 19:07















    0














    to add authorization, you may need to add a header:



    auth := "{user}:{password}"
    basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
    request.Header.Add("Proxy-Authorization", basicAuth)





    share|improve this answer




























      0














      to add authorization, you may need to add a header:



      auth := "{user}:{password}"
      basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
      request.Header.Add("Proxy-Authorization", basicAuth)





      share|improve this answer


























        0












        0








        0







        to add authorization, you may need to add a header:



        auth := "{user}:{password}"
        basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
        request.Header.Add("Proxy-Authorization", basicAuth)





        share|improve this answer













        to add authorization, you may need to add a header:



        auth := "{user}:{password}"
        basicAuth := "Basic " + base64.StdEncoding.EncodeToString(byte(auth))
        request.Header.Add("Proxy-Authorization", basicAuth)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 7:56









        danicheetadanicheeta

        994517




        994517






























            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%2f53406874%2fhow-to-use-proxies-with-authentication-in-my-http-requests%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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()