Hello,
I try to generate a Jwt Token from a JS app in order to be able to reach one of my server.
Mainly I called :
Auth0.loginWithRedirect(…)
and then
Auth0.handleRedirectCallback()
but the call back fails with a call to auth/token with a 401 error.
Here is my code:
const callSso = () => Auth0({ domain: ‘dev-9-wveqkg.eu.auth0.com’, client_id: ‘7uvYO9Vtc1QxQQuSavv0Xin2vcY5h1ns’ });
const getJwtToken = async () => {
if(jwtPromise === undefined) {
jwtPromise = await callSso();
}
if (window.location.search.includes(“code=”)) {
await jwtPromise.handleRedirectCallback(window.location.href);
window.history.replaceState(window.location.href, document.title, window.location.origin + window.location.pathname + window.location.hash);
}
const isAuth = await jwtPromise.isAuthenticated();
if(isAuth) {
return decodeToken(jwtPromise);
}
const retUrl = window.location.protocol + ‘//’ + window.location.host + window.location.pathname;
await jwtPromise.loginWithRedirect({redirect_uri: retUrl, response_type:‘id_token token’, scope:‘name openid’});
// never return we have redirected
return new Promise((_sucess) => {});
}
I try to compile and run the react sample and it gives the exact same error.