Getting a 400 error when attempting to get an access token from zoom.us/oauth/token

Description
Hello. After authentication I am getting a code that’s attached to the redirect URL, then I am making a post request to the server with this code in the request body where I am trying to get an access token

Error
{“error”:{“message”:“Request failed with status code 400”,“name”:“Error”,“stack”:“Error: Request failed with status code 400\n at createError (/workspace/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/workspace/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/workspace/node_modules/axios/lib/adapters/http.js:236:11)\n at IncomingMessage.emit (events.js:412:35)\n at endReadableNT (internal/streams/readable.js:1317:12)\n at processTicksAndRejections (internal/process/task_queues.js:82:21)”,“config”:{“url”:“https://zoom.us/oauth/token?code=xxxxxxxxxxxxxxxxxxxxxxx&grant_type=authorization_code&redirect_uri=https://app.butternbinge.com/trending",“method”:“post”,“data”:null,“headers”:{“Accept”:"application/json, text/plain, /”,“Content-Type”:“application/x-www-form-urlencoded”,“Authorization”:“Basic xxxxxxxxxxxxxxxx”,“User-Agent”:“axios/0.19.2”},“transformRequest”:[null],“transformResponse”:[null],“timeout”:0,“xsrfCookieName”:“XSRF-TOKEN”,“xsrfHeaderName”:“X-XSRF-TOKEN”,“maxContentLength”:-1}}}

Which App Type (OAuth / Chatbot / JWT / Webhook)?
OAuth

Which Endpoint/s?
https://zoom.us/oauth/token?code=${req.body.code}&grant_type=authorization_code&redirect_uri=https://app.butternbinge.com/trending

How To Reproduce (If applicable)
Steps to reproduce the behavior:
Here’s the code I am using

const zoomRes = await axios.post(
  `https://zoom.us/oauth/token?code=${req.body.code}&grant_type=authorization_code&redirect_uri=https://app.butternbinge.com/trending`,
  null, {
    headers: {
      'Authorization': `Basic ${Buffer.from('ClientId' + ":" + 'ClientSecret')
        .toString("base64")}`,
      'Content-Type': 'application/x-www-form-urlencoded',
    }
  })

Additional context
I’ve tried modifying the request by changing the Content-Type to ‘application/json’ and the redirect URL to the one generated from the console. While I was experimenting, I only got 400 and 403 errors.

Hey @transcodedinc,

Thank you for reaching out to the Zoom Developer Forum. When making this request, are you receiving a body along with the 401 status code? I’m wondering if this has more information indicating the exact issue.

Thanks,
Max

1 Like

I will try to collect all the details to resolve it.

I do not get anything specific besides it. Here’s how it looks in preview:

error: {message: "Request failed with status code 400", name: "Error",…}
config: {,…}
data: null
headers: {Accept: "application/json, text/plain, */*", Content-Type: "application/x-www-form-urlencoded",…}
Accept: "application/json, text/plain, */*"
Authorization: "Basic Uxxxxxxp"
Content-Type: "application/x-www-form-urlencoded"
User-Agent: "axios/0.19.2"
maxContentLength: -1
method: "post"
timeout: 0
transformRequest: [null]
0: null
transformResponse: [null]
0: null
url: "https://zoom.us/oauth/token?code=P1Lm6LxxxxxdXff7hFNg&grant_type=authorization_code&redirect_uri=https://app.butternbinge.com/trending"
xsrfCookieName: "XSRF-TOKEN"
xsrfHeaderName: "X-XSRF-TOKEN"
message: "Request failed with status code 400"
name: "Error"
stack: "Error: Request failed with status code 400\n    at createError (/workspace/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/workspace/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/workspace/node_modules/axios/lib/adapters/http.js:236:11)\n    at IncomingMessage.emit (events.js:412:35)\n    at endReadableNT (internal/streams/readable.js:1317:12)\n    at processTicksAndRejections (internal/process/task_queues.js:82:21)"

My OAuth app has the following setup:
Intend to publish: Yes
Account Level

Our plan: All that we intend to do with it is to help users to create zoom meetings. The process is: user logs in (gets token), and thereafter can create events.

We also haven’t published the zoom project yet. Could something be related to the console settings blocking us from getting access tokens successfully?

Here’s what we have in the console settings:

App credentials:
Production:
After Zoom approves your app, the live app on the Zoom Marketplace will use these credentials.
To use production credentials without publishing your app, please generate a [Publishable URL]

Redirect URL for OAuth: https:// app .butternbinge.com/trending // splitted due to forum rules
Subdomain check — turned off
Add allow lists:
https:// app .butternbinge.com/ // splitted due to forum rules
http:// localhost:3000 // splitted due to forum rules
https:// app .butternbinge.com/trending // splitted due to forum rules

Feature:
Event subscriptions and Chat Subscription — turned off.

Scopes:
View all user meetings/meeting:read:admin
View and manage all user meetings/meeting:write:admin
View all user information/user:read:admin

Test the App Locally:
As I understood the process, in this section I need to install it before using it (logging with URL redirection, etc). So I did.

Additionally, I tested it all not locally (localhost or local server, etc).

Thank you :pray:

Hi @transcodedinc,

In the console/preview, where you see the error object, can you expand this to reveal the errorMessage associated with the 400?

Thanks,
Will