When loggin in to a website, A Bearer token is generated and echoed back from the server in a JSON reponse. After this, each request sends the generated token in the Authorization: BEarer header.
However, there is a API endpoint which reflects the request Origin header value in Access-Control-Allow-Origin and carries out Access-Control-Allow-Credentials: true to.
I minimize the request to the minimum info needed to make the request successfully and the session is held in the Authorization: Bearer . So, then, I tried to test it for CORS issues to get sensitive info.
But the Cross-domain is not attaching the Authorization header.
I'm using the console in Developer Tools from example.com open.
Using this code:
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','url', true);
req.withCredentials = true; req.send(null);
function reqListener() {
alert(this.responseText);
};
But still gets HTTP 401 Unauthorized due to the ausence of Authorization header.
Any comments?