# Passwordless flow using auth0-js does not work! Documentation is wrong too

**URL:** <https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140>\
**Category:** Get Help\
**Created:** [May 21, 2021, 3:08am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140 "2021-05-21T03:08:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![john18](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john18/32/25312_2.png) [@john18](https://community.auth0.com/u/john18)\
**Post date:** [May 21, 2021, 3:08am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/1 "2021-05-21T03:08:02Z")

</div>

Please include the following information in your post:

SDK: **auth0-js**  
SDK Version: **9.16.0**  
Platform Version: **Node 14.15.5**  
Application Type: **Regular Application (NextJS)**

Hello,

I’m trying to implement passwordless flow using the auth0-js SDK. I don’t want to use the Universal Login because the customisation offered are not sufficient enough.

My application is a “Regular Web Application” (NextJS). I’m not using nextjs-auth0 because that again wants me to use Universal Login which isn’t what we want.

We’ve also enabled the **Customize Login Page** in Auth0 Dashboard → Universal Login → Login → Customize Login Page. As well as enabled the `Passwordless OTP` grant for target application.

Following the Auth0 SDK here ([Auth0.js v9 Reference](https://auth0.com/docs/libraries/auth0js)) I’ve done the following at high level:

1. Initiate the Passwordless flow at the backend. I have to do the passwordless start at server side since client secret is now required (see this comment from auth0 dev: [Passwordless connection not working for tenants created after Jan 2, 2020 - #6 by thameera](https://community.auth0.com/t/passwordless-connection-not-working-for-tenants-created-after-jan-2-2020/36415/6))

};

1. user clicks the email link received in their inbox

2. Auth0 redirects to our callback pages (`http://localhost:3000/auth/callback`). The url that /callback has is something like (`http://localhost:3000/callback#access_token=7Cl7_LLrWIpuEuuKSghAPRp00000000&scope=openid&expires_in=7200&token_type=Bearer`)

3. we handle the callback fragments using:

4. The **auth0.parseHash** at this point gives an error saying

At this point i don’t know what i’m doing wrong 😬 Is there a working example somewhere of how we’re meant to implement passwordless flow using **auth0-js** and regular application without using Universal Login? Would highly appreciate an example.

I also get this error ({error: “consent\_required”, error\_description: “Consent required”}) but i understand this is a localhost thing so i’m not too concerned about this for now.

To Auth0:

- Documentation of auth0-js isn’t updated anymore? If i just use the code sample from the documentation, that simply does not work.

Anyone knows what i’m doing wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![john18](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john18/32/25312_2.png) [@john18](https://community.auth0.com/u/john18)\
**Post date:** [May 24, 2021, 12:08am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/3 "2021-05-24T00:08:04Z")

</div>

Based on the conversation here ([`state` does not match - #2 by nicolas\_sabena](https://community.auth0.com/t/state-does-not-match/35148/2)), i can see why i am getting the `state does not match` error.

Issue is, Auth0 requires the passwordless flow to be started on server (see [Passwordless connection not working for tenants created after Jan 2, 2020 - #6 by thameera](https://community.auth0.com/t/passwordless-connection-not-working-for-tenants-created-after-jan-2-2020/36415/6)) otherwise you could get “Client authentication is required”.

In other words:

- if i start the passwordflow on server side, i get ``state` does not match` because obviously client doesn’t have the state.
- i cannot start the passwordless flow on client side because call to `/passwordless/start` requires client secret along side client id. If i don’t supply the client secret and try to start the passwordless flow on client side, i get `Client authentication is required`.

Would appreciate any help i can in solving this @thameera@andres.aguiar @konrad.sopala @nicolas_sabena

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [May 24, 2021, 9:31am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/4 "2021-05-24T09:31:34Z")

</div>

Hey @john18 👋 I think there’s a bit of confusion here. The client secret is required only if it is a confidential app (i.e. a “regular web application” in Auth0 application terminology), as mentioned in the response you linked from the other thread.

If you are using frontend flows, you can still continue calling `/passwordless/start` without a client secret. For this, you must make sure that the application is marked as a Single Page Application.

Afterwards, you can use Auth0.js’s passwordless methods: [Auth0.js v9 Reference](https://auth0.com/docs/libraries/auth0js#passwordless-login)

---

<div class="post-metadata">

**Author:** ![john18](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john18/32/25312_2.png) [@john18](https://community.auth0.com/u/john18)\
**Post date:** [May 24, 2021, 9:51am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/5 "2021-05-24T09:51:17Z")

</div>

Thanks for replying @thameera. I’m building on top of NextJS and as per the guide that comes for Auth0 when you create your application, it wanted me to create “Regular Web App” for nextjs. So is this correct:

- Regular web app: where you need the server to know about the user’s auth state, which is managed by nextjs-auth0

- SPA where Auth0.js does it’s thing and for all the API calls one must pass the Bearer token and have the APIs validate the token as needed?

Roughly correct?

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [May 24, 2021, 10:04am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/6 "2021-05-24T10:04:31Z")

</div>

That’s right! Next.js can be used both as a SPA and an RWA.  
As a SPA - you would start the login at the frontend and get the tokens in the frontend.  
As an RWA - both of those will happen at the backend. The callback URL would be a backend endpoint (eg: `https://example.com/api/callback`)

Generally RWAs are preferred, and Auth0’s Next.js SDK uses that pattern as well: [GitHub - auth0/nextjs-auth0: Next.js SDK for signing in with Auth0](https://github.com/auth0/nextjs-auth0)  
The SDK uses Auth0’s universal login page.

Technically, you’ll be able to get passwordless working with a backend flow as well. You’ll need to set the `responseType` to `code` and make sure the callback URL is a backend endpoint. I’ll not go into detail here.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 24, 2021, 10:14am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/7 "2021-05-24T10:14:44Z")

</div>

Thanks for helping on this one Thameera!

---

<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:** [June 8, 2021, 10:15am UTC](https://community.auth0.com/t/passwordless-flow-using-auth0-js-does-not-work-documentation-is-wrong-too/63140/8 "2021-06-08T10:15:09Z")

</div>

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