Copy link to clipboard
Copied
Hello Community,
i need help with this problem.
I would like to use the :
JWT Authorization header using the Bearer scheme. Example: "Authorization: Bearer {token}"
Someone can help me? I know, how can read an xml from a APi but without a header autentication. I need to know how can i pass trow the header this kind of token.
Thanks a lot
Hi.
If you're using XMLHttpRequest, you could so something like this:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
console.log("request complete");
};
xhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem("jwtoken"));
xhttp.open("GET", "filename", true);
xhttp.send();
https://www.w3schools.com/xml/xml_http.asp
https://stackoverflow.com/questions/52685215/how-to-send-jwt-in-xmlhttprequest
...Copy link to clipboard
Copied
Hi.
If you're using XMLHttpRequest, you could so something like this:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
console.log("request complete");
};
xhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem("jwtoken"));
xhttp.open("GET", "filename", true);
xhttp.send();
https://www.w3schools.com/xml/xml_http.asp
https://stackoverflow.com/questions/52685215/how-to-send-jwt-in-xmlhttprequest
Have you tried it?
Please let us know.
Regards,
JC
Copy link to clipboard
Copied
Hello Joao, you already help me (i changed to a new account but in the past already asked and you answered) anyway thanks!
i am trying to use something like this :
var reqCurrent = new XMLHttpRequest();
reqCurrent.open("GET", "URL", true);
reqCurrent.setRequestHeader('Authorization', 'Bearer ' + 'Token');
reqCurrent.addEventListener("load", currentLoader);
reqCurrent.send();
but i getting "CORS Policy error" , this is from server configuration or my fault?
Thanks a lot,
Copy link to clipboard
Copied
Awesome! Really good to know!
Have you tried something like this:
xhttp.setRequestHeader("Access-Control-Allow-Origin", "*");
If that doesn't work, then you probably have to configure the server.
Copy link to clipboard
Copied
It doesn't work.... i think is something from server configuration...
Copy link to clipboard
Copied
Hello again.
Sorry for the late reply.
Did you manage to solve the problem? If it's really a server issue, I don't think I'll be able to help you much. I'm a front-end guy.
Copy link to clipboard
Copied
no i can not solve.... so it's server side.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now