In client side I have written my code as below,
$.ajax({
type: "GET",
beforeSend: function (request) {
var jwt = document.head.querySelector("[name~=token][content]").content;
request.setRequestHeader("Authorization", 'JWT '+ jwt);
},
url: "/test",
success: function(data){
alert("success");
}
});
using this ajax request from client side I want to get the data on server side by authenticating the jwt token sent from client side. Server side(router code) is below,
app.get('/test', addon.checkValidToken(), function(req, res){
....
});
So, how can I authenticate or validate the url using jwt token by sending through request.SetHeaderRequest? I referred this url, but I couldn't figure out any solution for it.
Hey Hari,
I'm not a developer (giant disclaimer!) but I did read through the Atlassian Connect document you linked and noticed that the document expects you to have set the token somewhere client-side already. I see you've got a line to try and fetch it from the document head. Have you double-checked that it's actually set? Otherwise it looks good to me (again, not a developer) based on the Connect documentation.
We also have a dedicated Developer Community that might be good to check out for plugin development related questions. Since the topics are more focused, it's easier for other developers to watch the questions coming in and provide guidance.
Cheers,
Daniel
Hi @Daniel Eads,
Yes the value is set to the document head. But, authorization fails as that JWT token on server side throws the error 401. Also found a topic similar to my case in developer community, unfortunately there was no solution. So, I have posted a topic in developer community. Thanks a lot.
Cheers,
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.