Friday, 30 August 2019

How do I make sure the curl request gets the username and password appended via angular?

I am hosting my angular web application using static files and running into 401 error .

PROBLEM DESCRIPTION:

my web application prompts for username and password when you try to load it,even though I enter the correct username and password I get a 401 error, upon debug I notice the curl request doesn't have the username and password appeneded while requesting,as soon as I add the username and password to the curl request it passes(see below),how do I make sure the curl request gets the username and password appended via angular?

Following is my curl request which is failing

curl 'https://ibait.company.com/runtime-es2015.858f8dd898b75fe86926.js' -XGET -H 'Origin: https://ibait.company.com' -H 'Accept: */*' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15' -H 'Referer: https://ibait.company.com/'
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>AppleHttpServer/54b48526</center>
</body>
</html>

As soon as I add username and password to the curl request it passes

curl -u username:password 'https://ibait.company.com/runtime-es2015.858f8dd898b75fe86926.js' -XGET -H 'Origin: https://ibait.company.com' -H 'Accept: */*' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15' -H 'Referer: https://ibait.company.com/'

UPDATE(A sample API call in component.ts)

get_radar_lifecycle_data(){
    this.http.get('https://radar-life-cycle.usspk02.hoster.company.com/api/radar_life_cycle',{params})
        .subscribe(response => {
        console.log("radar data:");
         console.log(response);
         this.newPost = response
     });
}



from How do I make sure the curl request gets the username and password appended via angular?

No comments:

Post a Comment