Monday.com 集成到 chrome 扩展

Monday.com integration to chrome extansion

你好,我正在尝试将星期一集成到我的 chrome 扩展中,我正在接收授权代码,当我请求令牌以换取授权代码时,我收到了 code 500 有人能给我指出正确的方向吗

我正在使用的一些代码

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)
      });

      }
    );

查看官方文档:https://apps.developer.monday.com/docs/oauth#token-request

据我所知,您应该在发出令牌的请求中更改一些事项:

  1. 使用POST代替GET
  2. 除了代码之外,client_id 和 client_secret 您还应该发送 redirect_uri 参数,您在第一个授权请求中使用了该参数。 “此参数仅用于验证(没有实际重定向)。该值必须与授权请求步骤中提供的值匹配。”