Issue with https://....eu.auth0.com/oauth/token API

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.

1 Like

Hard to say what’s going wrong. Could you capture a HAR file and upload here? https://auth0.com/docs/tutorials/troubleshootings-with-har-files (Make sure you remove any confidential information from HAR file such as username & pwd before uploading here).

Also have you compared your implementation with one of the official quickstarts? Auth0

Hello,

Here is the har file zipped :
localhost.zip.har (3.2 MB)
It is also failing with the sample react project.

Cdt,

SK

1 Like

@sku are you by any chance using Regular Web Application as your Application type? What is the Token Endpoint Authentication method for your app? It should be Single Page Application type and Token Endpoint Authentication Method should be set to None.