Sample SPA App 01-Login fails, why?

I created an account
I get the sample app
I installed it,
fixed settings in the dashboard
filled auth_config.son
npm start
first login using a precreated user
dialog show up, fine
seems to work
but the user is not logged
locking in the console I see:

User not authenticated
app.js:115 > Parsing redirect
http.ts:13 POST https://dev-s8p4a31fmdaya02c.us.auth0.com/oauth/token 401
T @ http.ts:13
O @ http.ts:33
j @ http.ts:90
method @ http.ts:108
x @ api.ts:22
_requestToken @ Auth0Client.ts:1094
handleRedirectCallback @ Auth0Client.ts:522
window.onload @ app.js:117
load (async)
(anonymous) @ app.js:77
app.js:125 Error parsing redirect: Error: Unauthorized
at method (http.ts:145:11)
at async x (api.ts:22:3)
at async ce._requestToken (Auth0Client.ts:1094:11)
at async ce.handleRedirectCallback (Auth0Client.ts:534:5)
at async window.onload (app.js:117:22)
ui.js:88 UI updated

:frowning:

I thought the sample would work.

I tried with a new user, in the incognito window, using a sign up user

same

in the history on the dashboard, both users logged in successfully

Now, what should I do? Debug the sample?

tried again in Safari (I was in chrome)

[Log] > User not authenticated (app.js, line 110)
I dump code and state, they seem ok
[Log] > Parsing redirect – “4T1Ow8pOyg30Ar8aNNNRkOujg464Kc37i6VMnBg7p5CgB” – “NVR+S3lRR2I4aFBXb0Zza2FzRVpGUG40Nk11UnZ5SmNhbC5XNFpVUWN3Qg==” (app.js, line 117)
[Log] Error parsing redirect: – Error: Invalid state — Auth0Client.ts:496 (app.js, line 127)
Error: Invalid state — Auth0Client.ts:496

Hi there @BrunoWinck welcome to the community!

Sorry to hear you’re having issues with one of our sample apps - Which one are you working with in particular? Do you see the same issue if you 1. Log in to your Auth0 tenant and 2. download the sample from a quickstart directly so that it’s pre-configured to your tenant/app settings? I recommend clearing browser history prior to doing so just to be safe :smile:

Keep us posted!

Yes, that’s what I did. I followed the onboarding process scrupulously.

Le app is 01-Login, it came as a zip, and no, it was not pre-configured, but the tutorial explains how to do.

From auth pov, the login is successful. It’s the redirect that fails. I understand the redirect is meant to allow the client to store the code and state.

I followed Auth0 JavaScript SDK Quickstarts: Add login to your JavaScript App but using the zip, not the code in the tutorial.

Now that I have checked your link, the code has visible differences.
The code on github is similar to the one I received from the zip.

createAuth0Client is called with

{
    domain: config.domain,
    clientId: config.clientId
}

while in the tutorial it is

auth0.createAuth0Client({
  domain: "YOUR_DOMAIN",
  clientId: "YOUR_CLIENT_ID",
  authorizationParams: {
    redirect_uri: window.location.origin
  }

Which one is the good one?

Tried again by updating with the code above and resetting browser cache (incognito windows)

same:

User not authenticated
app.js:120 > Parsing redirect E4xI5jBW09lTdHcW2fSGjzy65pSvC9_wdYJsJIJ10e0QU a3NSYWlPYTdtVnRhOX5MSnY3aHNMczVTTWVOcXA1WW9fNkFCT2Vhc2E3RA==
app.js:46 Fetch finished loading: GET “http://localhost:3000/auth_config.json”.
fetchAuthConfig @ app.js:46
configureClient @ app.js:52
window.onload @ app.js:82
load (async)
(anonymous) @ app.js:81
http.ts:13 POST https://dev-s8p4a31fmdaya02c.us.auth0.com/oauth/token 401
T @ http.ts:13
O @ http.ts:33
j @ http.ts:90
method @ http.ts:108
x @ api.ts:22
_requestToken @ Auth0Client.ts:1094
handleRedirectCallback @ Auth0Client.ts:522
window.onload @ app.js:122
load (async)
(anonymous) @ app.js:81
app.js:130 Error parsing redirect: Error: Unauthorized
at method (http.ts:145:11)
at async x (api.ts:22:3)
at async ce._requestToken (Auth0Client.ts:1094:11)
at async ce.handleRedirectCallback (Auth0Client.ts:534:5)
at async window.onload (app.js:122:22)
ui.js:88 UI updated
http.ts:13 Fetch failed loading: POST “https://dev-s8p4a31fmdaya02c.us.auth0.com/oauth/token”.

Weird enough the dashboard says: last login : 2 minutes ago

So the pb is not th elogin but fetching a token after.

Sadly the library doesn’t provide very helpful error messages.

From my POV it’s an error either in the library or in the server.