-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api Invalid Token #34
Comments
OpenTAKServer uses sessions, not basic auth. First you need to make a GET request to |
here is my api.jsx
this is my page. im still getiing an error 401 unauthorized |
Your code seems good so I went back to look how the UI logs in. Here is its axios.create() export default axios.create({
withCredentials: true,
withXSRFToken: true,
maxRedirects: 0,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}); Try adding those properties to your axios.create() and see if that helps. |
I am building a new Frontend for the ots api but at each turn i am getting "invalid token" and "unauthorized as response"
what could be the issue i habve attached my code below. This smae request works with postman.
export const getEUDSWithBasicAuth = async (csrfToken) => {
//console.log(csrfToken)
const username = 'administrator';
const password = 'password';
const basicAuth = 'Basic ' + btoa(username + ':' + password);
try {
const response = await api.get('/eud', {
withCredentials: true,
headers: {
'Authorization': basicAuth,
//'XSRF-TOKEN':
${csrfToken}
,"XSRF-TOKEN":"ImI5N2ExZTVkZWM5YTVmZWFkYTE0ZmFlMzIzNWRkODA5YTcwODFlMDgi.ZmqvSw.YnmEd_Qx1iYASXa1QdD-ISUB-KE"
}
});
} catch (error) {
console.error("Error status:", error?.response?.status);
console.error("Error data:", error?.response?.data);
throw error;
}
};
The text was updated successfully, but these errors were encountered: