google-chrome-extensionoauth-2.0monday.com

Monday.com integration to chrome extansion


hello i am trying to integrate Monday to my chrome extension, I am receiving the auth code and when i request token in exchange for the auth code i am receiving code 500 can someone point me to the right direction

some of the code I am using

chrome.identity.launchWebAuthFlow(
      {
        interactive: true,
        url: `https://auth.monday.com/oauth2/authorize?client_id=${MONDAY_CLIENT_ID}&state=${MONDAY_STATE}&redirect_uri=${MONDAY_REDIRECT_URI}&scope=me:read+boards:read+boards:write+updates:write`,
      },
      (url?: string) => {
        let code = url.substring(url.indexOf("code=") + "code=".length);
        code = code.substring(0, code.indexOf("&"));

        const requestTokenUrl = new URL("https://auth.monday.com/oauth2/token");
        const params = { code, client_id:MONDAY_CLIENT_ID ,client_secret:CLIENT_SECRET};

        requestTokenUrl.search = new URLSearchParams(params).toString();
        axios.get(requestTokenUrl.toString()).then((res)=>{
          console.log(res.data)
      });

      }
    );

Solution

  • Check out the official documentation: https://apps.developer.monday.com/docs/oauth#token-request

    From what I see, there are a few things you should change in your request to issue a token:

    1. Use POST instead of GET
    2. In addition to code, client_id and client_secret you should send redirect_uri param, which you used in the first authorize request. "This parameter is used for validation only (there is no actual redirection). The value must match the value supplied in the Authorization Request step."