# Unable to get OAuth access token

**URL:** <https://devforum.zoom.us/t/unable-to-get-oauth-access-token/73653>\
**Category:** Meeting SDK\
**Created:** [August 4, 2022, 3:29pm UTC](https://devforum.zoom.us/t/unable-to-get-oauth-access-token/73653 "2022-08-04T15:29:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdeveloper](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rdeveloper/32/33383_2.png) [@rdeveloper](https://devforum.zoom.us/u/rdeveloper)\
**Post date:** [August 4, 2022, 3:29pm UTC](https://devforum.zoom.us/t/unable-to-get-oauth-access-token/73653/1 "2022-08-04T15:29:15Z")

</div>

Hello,

I’m using Web Meeting SDK, app level is user level. I’m building a web app using the framework React and Node JS. My goal is to be able to schedule Zoom meetings directly from my website.

I’m using OAuth for authentication, so I followed the [Zoom OAuth Sample App](https://github.com/zoom/zoom-oauth-sample-app). I actually tried to run that sample app but I kept getting “500 Internal Server Error” and was not able to find a solution for it. I attempted to do it on my own website anyway, and I got stuck with 2 errors.

I ran the code from the sample app in a local port in the back-end. Code is pretty much the same, but here it is just in case:

```auto
app.get('/', (req, res) => {

  if (req.query.code) {

      let url = 'https://zoom.us/oauth/token?grant_type=authorization_code&code=' + req.query.code + '&redirect_uri=' + process.env.REACT_APP_REDIRECT_URL;

      request.post(url, (error, response, body) => {

          body = JSON.parse(body);
          console.log(`access_token: ${body.access_token}`);
          console.log(`refresh_token: ${body.refresh_token}`);

          if (body.access_token) {

          // Create meeting API goes here

      }).auth(process.env.REACT_APP_CLIENT_ID, process.env.REACT_APP_CLIENT_SECRET);

      return;
  }

  res.redirect('https://zoom.us/oauth/authorize?response_type=code&client_id=' + process.env.REACT_APP_CLIENT_ID + '&redirect_uri=' + process.env.REACT_APP_REDIRECT_URL)
})

app.listen(3008, () => console.log(`Zoom app listening at PORT: 3008`))

```

On the front end, I’m calling this, triggered by clicking a Create Meeting button:

```auto
     const handleSubmit = (event) => {
        event.preventDefault();
        console.log(inputs);

          const meetingData = {
            email: "[my admin zoom email]",
            topic: inputs.title,
            password: inputs.password,
            start_time: inputs.dateTime,
            // more options etc
          }

          try {
            console.log("Calling auth API")
            axios.get('http://localhost:3008/', meetingData)
            .then((response) => {
                // Create meeting successful!
            }, (error) => {
              console.log('Zoom API failed: ' + error.response.data);
            });
          } catch (error) {
            console.log(error);
          }

```

The errors I got:

 ![Screen Shot 2022-08-05 at 1.18.15 am](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/f/3/f3f27e2b92599ad6a6ccf80ef63bf34770d85573.png)

For the first CORS error, I attempted by setting the headers in my server-side code, just above the get method:

```auto
app.use((req, res, next) => {
    res.setHeader("Access-Control-Allow-Origin", "http://localhost:3008");
    res.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS");
    if (req.method == "OPTIONS") {
      return res.sendStatus(200);
    }
    next();
  });

```

Now, there’s still a CORS error, but it’s a slightly different one:

 ![Screen Shot 2022-08-05 at 1.23.21 am](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/b/b/bb289e70366fcb8697437a89abc0d73c828d7910.png)

I spent a lot of hours trying to figure them out now, I’m probably missing something completely. If anyone is able to point me to the right direction, that would be very appreciated!
