Unable to run zoomapps-sample-js

I just went through the tutorial video on YouTube: tutorial, sample app, and done everything in the video. In the last step, when i launched the zoom app, the app was launched, but it pops out an error “An unknown error occurred, Error code: 122”. I cannot resolve it, and I didn’t find information about this error.

OS: Ubuntu 22.04 LTS

Welcome, @thr ,

Thank you for posting in the Zoom Developer Forum and I am happy to help! As a start, can you share the error message you are seeing and the steps to reproduce if possible?

  1. i git clone the zoomapps-sample-js from GitHub - zoom/zoomapps-sample-js: A Hello World Zoom App built with Vanilla JS
  2. run npm install in the directory
  3. run ngrok http 3000 and create and config a zoom app on zoom market.
  4. config the .env file in the git cloned file.
  5. access the https://…ngrok.io that generate by ngrok http 3000
  6. click the localhost:3000 and the zoom is launched and a few seconds later, then an error occurred: “An unknown error occurred, Error code: 122”.

if i click https://…ngrok.io/auth
then i receive this

Error 400
invalid state parameter

BadRequestError: invalid state parameter
    at handleError (file:///home/user/Documents/zoomapps_sample/server/helpers/routing.js:35:12)
    at file:///home/user/Documents/zoomapps_sample/server/routes/auth.js:55:14
    at Layer.handle [as handle_request] (/home/user/Documents/zoomapps_sample/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/user/Documents/SURE/zoomapps_sample/node_modules/express/lib/router/route.js:137:13)
    at middleware (/home/user/Documents/zoomapps_sample/node_modules/express-validator/src/middlewares/check.js:16:13)

Instead of navigating to the auth route to install the app, try opening the home page in a browser. You should see a link to install the app which will generate a state and start the authorization flow.

Let me know if that helps :slightly_smiling_face:

1 Like

Any updates to this? I have the same issue.

Are you navigating directly to the /auth page or are you clicking the install link from the home page? Using the install link from the home page is what you’ll want to do with this app as it will generate the state parameter that needs to be verified.

I hope that helps!

@patrick4 @thr I was able to reproduce this behavior on my end and am working to push out a fix ASAP

@MaxM Great news! Please keep us updated.

It seems like the session is being cleared when redirecting to the /auth handler, hence the validation (checking if the query parameters matches the session parameters) fails, not sure if this is the intended behavior

@patrick4 @shunji.lin @thr

I took a look into this and got everything working by updating dependencies and cloning a fresh copy.

Are you still running into this issue when re-cloning the repo?

I recloned the repo and still face the same error:

Error 400
invalid state parameter

BadRequestError: invalid state parameter
    at handleError (file:///home/shunji/zoomapps-sample-js/server/helpers/routing.js:35:12)
    at file:///home/shunji/zoomapps-sample-js/server/routes/auth.js:55:14
    at Layer.handle [as handle_request] (/home/shunji/zoomapps-sample-js/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/shunji/zoomapps-sample-js/node_modules/express/lib/router/route.js:137:13)
    at middleware (/home/shunji/zoomapps-sample-js/node_modules/express-validator/src/middlewares/check.js:16:13)

as mentioned in the previous reply, it seems the session does not persist between the redirect from the /install to the /auth handler, this does not seem to be a problem with repo.

It seems like the documentation recommends to store the code_verifier and state_noonce in the db and not in the session, so maybe this is the issue?

I am also getting a similar error from the advanced app example, it is also retrieving the state from the session

Error: Invalid state parameter
    at auth (/home/node/app/api/zoomapp/controller.js:173:21)
    at Layer.handle [as handle_request] (/home/node/app/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/node/app/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/home/node/app/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/home/node/app/node_modules/express/lib/router/layer.js:95:5)
    at /home/node/app/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/home/node/app/node_modules/express/lib/router/index.js:346:12)
    at next (/home/node/app/node_modules/express/lib/router/index.js:280:10)
    at Function.handle (/home/node/app/node_modules/express/lib/router/index.js:175:3)
    at router (/home/node/app/node_modules/express/lib/router/index.js:47:12)

Can you point me to what section of the documentation you are referring to?

What platform, browser and browser version are you testing with? I just want to make sure I’m attempting to reproduce the issue in the same way.

I am using windows 11, firefox version 110.0.1 as well as chrome 110.0.5481.178

Thanks for sharing that information. I tested this out on Windows 11 using Chrome 111.0.5563.65 but I wasn’t seeing the same issue.

Does this happen when using an incognito window as well?

Getting same thing on this sample app:

Tried on incognito too.

Navigating to localhost:3000, then clicking the install link, then going through Zoom OAuth, then redirected back and getting:
“Error 400
invalid state parameter”

Thanks for getting back to me on this. I sent you a DM to schedule a meeting to debug this as I’m not able to see the same behavior on my end.

I had this issue. I wasn’t using ngrok but a cloud provider. By enabling debug logging I was eventually able to see that cookie-session wasn’t able to save the cookies because it didn’t believe it was a secure connection - the cloud server was terminating TLS.

I turned on trusting the proxy headers (app.set('trust proxy', true)) and now all is good.

Thanks for sharing your solution here! I’ll look at implementing this in the official repo