Example App - HTML + Express.js Error

Hi I cloned your gh repo for the “email magic links using stytch.js” Example App. I’m able to load the website locally → enter my email → receive an email with magic link → as soon as I click on the link it redirects to a page that says “There was an error authenticating the user” (yes I inputted the appropriate credentials in my .env file and I added the redirect URL with the correct path). Any help here is greatly appreciated!

Hey Hasan – thanks for posting!

It looks like you’ve been running into pkce_expected_code_verifier errors while attempting to use our stytchjs-html-express example app. This is because this specific example app isn’t set up to work with our Proof Key for Code Exchange (PKCE) feature – sorry for the confusion!

This example app starts the authentication flow via our frontend JavaScript SDK but completes the flow via our backend Node client library, which is why PKCE isn’t handled automatically as it is when our JavaScript SDK is used for the entire flow. If you check out our stytch-nextjs-integration example app instead, you’ll notice that PKCE is supported out of the box.

If you’d like to continue using our stytchjs-html-express example app, I’d recommend turning off PKCE for the time being via the SDK configuration tab in the Stytch Dashboard (under the “Email Magic Links” section).

It’s also totally possible to set up PKCE via one of our backend authentication flows, it just takes a few more steps that we haven’t yet implemented in stytchjs-html-express.

Please let me know if you have any additional questions about this, and I’ll be happy to help!