# Sample SPA App 01-Login fails, why?

**URL:** <https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039>\
**Category:** Get Help\
**Tags:** certificate-rollover, connections\
**Created:** [December 23, 2022, 6:58pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039 "2022-12-23T18:58:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrunoWinck](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brunowinck/32/40550_2.png) [@BrunoWinck](https://community.auth0.com/u/BrunoWinck)\
**Post date:** [December 23, 2022, 6:58pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/1 "2022-12-23T18:58:29Z")

</div>

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](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

☹

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?

---

<div class="post-metadata">

**Author:** ![BrunoWinck](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brunowinck/32/40550_2.png) [@BrunoWinck](https://community.auth0.com/u/BrunoWinck)\
**Post date:** [December 23, 2022, 8:32pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/2 "2022-12-23T20:32:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 24, 2022, 12:47am UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/3 "2022-12-24T00:47:06Z")

</div>

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 😄

> **[Auth0 Single-Page App Quickstarts](https://auth0.com/docs/quickstart/spa)**
>
> Browse single-page app quickstarts to learn how to quickly add authentication to your app.

Keep us posted!

---

<div class="post-metadata">

**Author:** ![BrunoWinck](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brunowinck/32/40550_2.png) [@BrunoWinck](https://community.auth0.com/u/BrunoWinck)\
**Post date:** [December 24, 2022, 1:57am UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/4 "2022-12-24T01:57:22Z")

</div>

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](https://auth0.com/docs/quickstart/spa/vanillajs/interactive) 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

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

```

while in the tutorial it is

```auto
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](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](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](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.

---

<div class="post-metadata">

**Author:** ![vuesomedev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vuesomedev/32/53513_2.png) [@vuesomedev](https://community.auth0.com/u/vuesomedev)\
**Post date:** [December 26, 2023, 7:01pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/5 "2023-12-26T19:01:19Z")

</div>

Same issue for me…did you find out the problem?

---

<div class="post-metadata">

**Author:** ![sebastian.celejewski](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sebastian.celejewski](https://community.auth0.com/u/sebastian.celejewski)\
**Post date:** [January 10, 2024, 12:14pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/6 "2024-01-10T12:14:45Z")

</div>

I am experiencing the same problem:

- Sample application
- Logs in dashboard show successful authentication
- Method auth0Client.handleRedirectCallback fails with Error parsing redirect: Error: Unauthorized

---

<div class="post-metadata">

**Author:** ![sebastian.celejewski](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sebastian.celejewski](https://community.auth0.com/u/sebastian.celejewski)\
**Post date:** [January 10, 2024, 12:20pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/7 "2024-01-10T12:20:59Z")

</div>

Solution: Change “Authentication method” to “None” in “Credentials” tab of “Application” configuration page.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [November 25, 2024, 7:12pm UTC](https://community.auth0.com/t/sample-spa-app-01-login-fails-why/97039/8 "2024-11-25T19:12:02Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
