monday-sdk-js icon indicating copy to clipboard operation
monday-sdk-js copied to clipboard

monday.oauthToken always fails

Open ionscorobogaci opened this issue 2 years ago • 0 comments

Describe the bug Using monday sdk on server side to exchange the code for an token fails with an empty error

Steps to reproduce

  1. Embed the SDK in an app
  2. Call monday.oauthToken( "code", MONDAY_APP_CLIENT_ID, MONDAY_APP_CLIENT_SECRET )
  3. See the request fails with an empty error
  4. ...

Expected behavior auth token should be returned

Context and environment Used inside lambda function on NodeJs environment

Additional information Although in the documentation is specified that the parameters should be sent as x-form-urlencoded : https://apps.developer.monday.com/docs/oauth Screenshot 2022-08-03 at 21 05 28 looks like the library itself is not respecting that and is using body as string :

await fetch.nodeFetch(url, {
    method: options.method || "POST",
    body: JSON.stringify(data || {}),
    headers: {
      Authorization: token,
      "Content-Type": "application/json"
    }
  });

in oauth-service.js

execute(data, null, { url: MONDAY_OAUTH_TOKEN_URL });

this method is invoked which uses inside body as string

this can be the issue probably...

ionscorobogaci avatar Aug 03 '22 18:08 ionscorobogaci