I am new to react and I am having a hard time figuring out this issue, so the backend is running on the Django, what I am trying to achieve is that from my frontend application I am able to log in to third party authentication system (Okta) on the API 127.0.0.1:8000/authenticate/login after the user is authenticated the page is redirected to the 127.0.0.1:8000/authenticate/saml where the tokens are generated for the user and that token are further used to get data from the database, I am having trouble to get to the part where I can fetch the token which are present in the JSON format
const Token = () => {
const urlLogin = "http://127.0.0.1:8000/authentication/login/";
const saml = 'http://127.0.0.1:8000/authentication/saml';
useEffect(() => {
// after the authentication is completed the used is directed to the token page
window.location.href=urlLogin;// here authentication is being done
const fetchApi = async () => {
fetch(saml, {
method: 'POST',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
}
}).then(response => console.log(response.read));
}
fetchApi();
}, []);