C# Request with RestClient to get access_token - don't understand why it IS working












-1















I finally managed to recieve a valid (302) response from a RestRequest pasted below, but I don't know why.



Its all about the line with the "Autorisation" and the given Hash:



request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");


This line I found in the Internet (including the given Hash) and when I change the Hash or just omitt the line completly, the response turns to a 400 as it was on about 20 other code examples I've tried so far.



Can anybody explain what is going on here? I would like to omitt the "Authorisation" line including the Hash if possible.



ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

string url = "https://myurl/oauth2/login?response_type=token";

var client = new RestClient(url);
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "client_id=XXXX&username=YYYY&password=ZZZZ&redirect_uri=", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);









share|improve this question























  • I am not sure I understand. Why are you surprised that it does work?

    – mjwills
    Jan 3 at 11:30






  • 1





    Because I'm using an AUTHORISATION Header and Hash I found in the Internet and can't find any other Info about the Hash - When I change the Hash it doesn't work anymore. I would like to understand why THIS Hash works

    – Frank W
    Jan 3 at 11:33













  • Can you be super explicit about what you mean by the hash?

    – mjwills
    Jan 3 at 11:36











  • What authentication is your server configured to accept?

    – spodger
    Jan 3 at 12:19











  • Thanks everybody for your questions to help clarify my question.Unfortunately today my request that had been working yesterday is not working anymore today and I am unable to reach the administrator of the server. So let me close this question and wait for an answer of the server admin - thanks a lot for your efforts

    – Frank W
    Jan 4 at 14:10


















-1















I finally managed to recieve a valid (302) response from a RestRequest pasted below, but I don't know why.



Its all about the line with the "Autorisation" and the given Hash:



request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");


This line I found in the Internet (including the given Hash) and when I change the Hash or just omitt the line completly, the response turns to a 400 as it was on about 20 other code examples I've tried so far.



Can anybody explain what is going on here? I would like to omitt the "Authorisation" line including the Hash if possible.



ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

string url = "https://myurl/oauth2/login?response_type=token";

var client = new RestClient(url);
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "client_id=XXXX&username=YYYY&password=ZZZZ&redirect_uri=", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);









share|improve this question























  • I am not sure I understand. Why are you surprised that it does work?

    – mjwills
    Jan 3 at 11:30






  • 1





    Because I'm using an AUTHORISATION Header and Hash I found in the Internet and can't find any other Info about the Hash - When I change the Hash it doesn't work anymore. I would like to understand why THIS Hash works

    – Frank W
    Jan 3 at 11:33













  • Can you be super explicit about what you mean by the hash?

    – mjwills
    Jan 3 at 11:36











  • What authentication is your server configured to accept?

    – spodger
    Jan 3 at 12:19











  • Thanks everybody for your questions to help clarify my question.Unfortunately today my request that had been working yesterday is not working anymore today and I am unable to reach the administrator of the server. So let me close this question and wait for an answer of the server admin - thanks a lot for your efforts

    – Frank W
    Jan 4 at 14:10
















-1












-1








-1








I finally managed to recieve a valid (302) response from a RestRequest pasted below, but I don't know why.



Its all about the line with the "Autorisation" and the given Hash:



request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");


This line I found in the Internet (including the given Hash) and when I change the Hash or just omitt the line completly, the response turns to a 400 as it was on about 20 other code examples I've tried so far.



Can anybody explain what is going on here? I would like to omitt the "Authorisation" line including the Hash if possible.



ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

string url = "https://myurl/oauth2/login?response_type=token";

var client = new RestClient(url);
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "client_id=XXXX&username=YYYY&password=ZZZZ&redirect_uri=", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);









share|improve this question














I finally managed to recieve a valid (302) response from a RestRequest pasted below, but I don't know why.



Its all about the line with the "Autorisation" and the given Hash:



request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");


This line I found in the Internet (including the given Hash) and when I change the Hash or just omitt the line completly, the response turns to a 400 as it was on about 20 other code examples I've tried so far.



Can anybody explain what is going on here? I would like to omitt the "Authorisation" line including the Hash if possible.



ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

string url = "https://myurl/oauth2/login?response_type=token";

var client = new RestClient(url);
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "client_id=XXXX&username=YYYY&password=ZZZZ&redirect_uri=", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);






c# oauth access-token rest-client






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 11:27









Frank WFrank W

11




11













  • I am not sure I understand. Why are you surprised that it does work?

    – mjwills
    Jan 3 at 11:30






  • 1





    Because I'm using an AUTHORISATION Header and Hash I found in the Internet and can't find any other Info about the Hash - When I change the Hash it doesn't work anymore. I would like to understand why THIS Hash works

    – Frank W
    Jan 3 at 11:33













  • Can you be super explicit about what you mean by the hash?

    – mjwills
    Jan 3 at 11:36











  • What authentication is your server configured to accept?

    – spodger
    Jan 3 at 12:19











  • Thanks everybody for your questions to help clarify my question.Unfortunately today my request that had been working yesterday is not working anymore today and I am unable to reach the administrator of the server. So let me close this question and wait for an answer of the server admin - thanks a lot for your efforts

    – Frank W
    Jan 4 at 14:10





















  • I am not sure I understand. Why are you surprised that it does work?

    – mjwills
    Jan 3 at 11:30






  • 1





    Because I'm using an AUTHORISATION Header and Hash I found in the Internet and can't find any other Info about the Hash - When I change the Hash it doesn't work anymore. I would like to understand why THIS Hash works

    – Frank W
    Jan 3 at 11:33













  • Can you be super explicit about what you mean by the hash?

    – mjwills
    Jan 3 at 11:36











  • What authentication is your server configured to accept?

    – spodger
    Jan 3 at 12:19











  • Thanks everybody for your questions to help clarify my question.Unfortunately today my request that had been working yesterday is not working anymore today and I am unable to reach the administrator of the server. So let me close this question and wait for an answer of the server admin - thanks a lot for your efforts

    – Frank W
    Jan 4 at 14:10



















I am not sure I understand. Why are you surprised that it does work?

– mjwills
Jan 3 at 11:30





I am not sure I understand. Why are you surprised that it does work?

– mjwills
Jan 3 at 11:30




1




1





Because I'm using an AUTHORISATION Header and Hash I found in the Internet and can't find any other Info about the Hash - When I change the Hash it doesn't work anymore. I would like to understand why THIS Hash works

– Frank W
Jan 3 at 11:33







Because I'm using an AUTHORISATION Header and Hash I found in the Internet and can't find any other Info about the Hash - When I change the Hash it doesn't work anymore. I would like to understand why THIS Hash works

– Frank W
Jan 3 at 11:33















Can you be super explicit about what you mean by the hash?

– mjwills
Jan 3 at 11:36





Can you be super explicit about what you mean by the hash?

– mjwills
Jan 3 at 11:36













What authentication is your server configured to accept?

– spodger
Jan 3 at 12:19





What authentication is your server configured to accept?

– spodger
Jan 3 at 12:19













Thanks everybody for your questions to help clarify my question.Unfortunately today my request that had been working yesterday is not working anymore today and I am unable to reach the administrator of the server. So let me close this question and wait for an answer of the server admin - thanks a lot for your efforts

– Frank W
Jan 4 at 14:10







Thanks everybody for your questions to help clarify my question.Unfortunately today my request that had been working yesterday is not working anymore today and I am unable to reach the administrator of the server. So let me close this question and wait for an answer of the server admin - thanks a lot for your efforts

– Frank W
Jan 4 at 14:10














1 Answer
1






active

oldest

votes


















0














Unfortunately today I cannot reproduce the successful request from yesterday anymore and I am having problems getting in touch with the server admin.
So thanks to all for your efforts to help answer my question.
It seems the best to be patient and wait for an answer from the server admin, so I would like to close this question.






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%2f54021402%2fc-sharp-request-with-restclient-to-get-access-token-dont-understand-why-it-is%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









    0














    Unfortunately today I cannot reproduce the successful request from yesterday anymore and I am having problems getting in touch with the server admin.
    So thanks to all for your efforts to help answer my question.
    It seems the best to be patient and wait for an answer from the server admin, so I would like to close this question.






    share|improve this answer




























      0














      Unfortunately today I cannot reproduce the successful request from yesterday anymore and I am having problems getting in touch with the server admin.
      So thanks to all for your efforts to help answer my question.
      It seems the best to be patient and wait for an answer from the server admin, so I would like to close this question.






      share|improve this answer


























        0












        0








        0







        Unfortunately today I cannot reproduce the successful request from yesterday anymore and I am having problems getting in touch with the server admin.
        So thanks to all for your efforts to help answer my question.
        It seems the best to be patient and wait for an answer from the server admin, so I would like to close this question.






        share|improve this answer













        Unfortunately today I cannot reproduce the successful request from yesterday anymore and I am having problems getting in touch with the server admin.
        So thanks to all for your efforts to help answer my question.
        It seems the best to be patient and wait for an answer from the server admin, so I would like to close this question.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 4 at 14:17









        Frank WFrank W

        11




        11
































            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%2f54021402%2fc-sharp-request-with-restclient-to-get-access-token-dont-understand-why-it-is%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

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas