To whom it may concern,
I have been trying to resolve this issue for the last 5-days and have been quite disappointed that I can’t seem to find any sort of documentation with regards to verifying if I can use Tokens to submit POST requests.
My current issue stems from a supposed final major bug with using Auth0 JWT Tokens, through the Client Credential Flow M2M method. Though I may understand that I am using a very unique setup:
- React Frontend
- Django Backend
- No user login intended to access secured API access
I guess it just now leads me to questioning on whether simply, “Can I even send POST requests to a Auth0 JWT Token secured backend?”. If it is possible, hope someone may redirect me to a potential solution, else, at least I know I really need to source something else entirely.
The potential solutions I do only see with a React frontend, is to actually build a:
- Express.js backend
- Enable user-account login access
This would not be ideal as both options are not the intended use case, and it will dramatically require me to change extensive code, especially to rebuild an entire backend. I was suppose to launch 2-3 weeks ago, but apparently now, this is the last security roadblock I am facing.
Hope some kind soul may help to redirect me on a potential solution on how can I send POST requests, with JWT Token validation, to a Django backend?
The current code I am using is as follows, and sadly, the GET option works, but this POST request option doesn’t seem to work:
let getBackendConfig = {
headers: {
"Content-Type": "application/json",
Authorization: process.env.REACT_APP_JWT_AUTH0_HEADER + " " + auth0Token,
},
};
async function submitLocationViaPOST( dataToPOST ) {
setIsLocationUploaded("process");
try {
Promise.all([
await axios
.post(urlSubmitLocationPOSTAPI, dataToPOST, getBackendConfig)
.then(response => {
console.log("👉 urlSubmitLocationPOSTAPI Reply Data: ", response);
if (response.status === 201) {
// EXECUTE ONLY IF RESPONSE IS "201" --- MEANING ENTRY CREATED SUCCESSFULLY
setIsLocationUploaded("finish");
}
})
]);
}
catch (err) {
setIsLocationUploaded("error");
console.log("😱 urlSubmitLocationPOSTAPI Error: " + err);
}
}