[OAuth] Request access token error!

Description

I test OAuth features and there are some problems
In my test env is local

I tried blow steps
1.Request user authorization on my frontend web(local test 127.0.0.1) and work well and redirected to URL that is on [Redirect URL for OAuth] of App credentials.
2.get a CODE from redirected querystring
3.call backend server(local test nodejs) with Returned CODE from step2
blow is my code

 app.get('/z1/:code', (req, res) => {

  var rcode = req.params.code;

  fetch("https://zoom.us/oauth/token", {
    method: "POST",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
      "Authorization":"Basic ZjhmSklINXNUNHVrSVQyc2I4Wk1OZzo5ODV1U3dSNkpkclJWcW1wWGljTkVzSkw0QThqMXZCMg=="
    },
    body: JSON.stringify({
      code:rcode,
      grant_type:'authorization_code',
      redirect_uri:'http://127.0.0.1:8080/eden/zoomredirect'
    }),
  }).then((response) => console.log(response));
      
  
});

but error is returned

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://zoom.us/oauth/token',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

I tested on Postman . but postman works well…
What was I wrong…

Hi @kerriganhjh
Thanks for reaching out to the Zoom Developer Forum, I am happy to help here!
It looks like you are passing the grant_type, the code and the redirect uri as a part of a body, when this should be included in your request url as query params, it should look something like this:

fetch("https://zoom.us/oauth/token?grant_type=authorization_code&code={yourCode} &redirect_uri={yourRedirectUri}/", requestOptions)

thanks. cool It’s my faults

another questions

When Publish my Web, Is it possible to call zoom api (OAuth get Access token and etc) on frontend?
Should I call Zoom API via my backend server?

@kerriganhjh
No worries! Happy that helped.
You should be getting Access token and calling API via backend :slight_smile: