OAuth "missing client_id" error

Surfacing this here bc it was buried in another thread…

Hi, I’m proceeding with OAuth testing. Not sure what the problem is but I get a response from the token service with the error

{“error”:“invalid_request”,“error_description”:“Missing client_id param”}

  (log) ControllerMonday: sending request to get token with - {"client_id":"NNNNN","client_secret":"NNNNN","redirect_uri":"MY_REDIRECT_URI","code":"NNNN"}
  (log) ControllerMonday: token response, getting access token
  (log) ControllerMonday: token response, body is - {"error":"invalid_request","error_description":"Missing client_id param"}

I’m receiving the redirect callback with the access code just fine. But, then I set all the values including “client_id” and calling https://auth.monday.com/oauth2/token and I get the response that “client_id” is missing…

I had a similar error when I first started testing OAuth for Monday apps and it was because my app settings had changed and I had to redeploy the app so that my OAuth settings had taken effect. But, my app hasn’t changed and I’ve verified the client_id and client_secret as well as the code being sent are correct.

But, at this point, I’m at a loss. I’m passing the client_id and what I thought was odd was that in the sample code that you referenced, they used this for their POST configuration:

GITHUB EXAMPLE CODE

    var authRequest = {
      url: 'THE_TOKEN_URI',
      form: {
        redirect_uri: redirect_uri + "/oauth/callback",
        client_id: client_id,
        client_secret: client_secret,
        code: code,
      },
    };

They’re using “form” instead of “body” to POST the data to the token service. I tried both with “body” and with “form” and get the same response. Here’s my code…

        // Call monday enpoint
        var config = {
            method: 'POST',            
            body: JSON.stringify({
                client_id: this.Env.MONDAY_CLIENT_ID,
                client_secret: this.Env.MONDAY_CLIENT_SECRET,
                redirect_uri: ControllerMonday.OAUTH_REDIRECT_URI,
                code: code     
            })
        };
        console.log("ControllerMonday: sending request to get token with - "+ config.body);
        var req = new Request(ControllerMonday.OAUTH_TOKEN_URI);
        var res = await fetch(req, config);      

Any ideas? Thanks

Are you sure its supposed to be in the body of the post? The documentation says they are “parameter” in the table, not “key” so that indicates they are part of the query string - which is what I found I had to do to make it work.

Query string parameters for POSTing data? Ok…

Yeah it seems quite weird but… its actually not against any specification as far as I know. POST is just for sending non-idempotent data in REST. Can be in the body or query string.

1 Like

Yep, thanks! Will report back when I finish testing, thanks again.