I am consuming an API with basic authentication oauth and returns: Incorrect request (400)

0

Talk, guys!

Next, I developed a spring boot api and I already tested it with the postman and it is working normally, its security is very basic auth authentication. Now I am testing in a C # application that I have here to return the token to be able to consume the endpoints, however when I am making the call to return the token it is returning me:

"System.Net.WebException: 'O servidor remoto retornou um erro: (400) Solicitação Incorreta.'"

Follow the code below:

        WebRequest req = WebRequest.Create(@"http://localhost:8080/oauth/token");
        req.Method = "POST";

        req.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("apisustentacao:HHednf8iwFgre$$$@"));
        HttpWebResponse resp = req.GetResponse() as HttpWebResponse;

No postman is working normally:

BelowismorepostmanHeaderimage:

Thanks to anyone who can help me

    
asked by anonymous 12.08.2018 / 17:49

0 answers