【问题标题】:Node.js Zoom API: invalid authorization codeNode.js Zoom API:授权码无效
【发布时间】:2021-10-19 09:37:08
【问题描述】:

根据本指南,我有一个用于将用户连接到 Zoom MarketPlace 的应用程序:https://marketplace.zoom.us/docs/guides/auth/oauth
用户重定向回我的页面后,我进行了安装,一切正常。问题是,当用户单击“连接”按钮时,使用查询字符串中的“代码”参数重定向回我的页面,等待大约 10 分钟,然后 尝试在服务器上安装 Zoom:我收到以下错误:“错误:invalid_request,原因:无效授权码”。
我在 Zoom 文档中的查询字符串中看不到任何与“code”参数的任何到期时间相关的内容。

这是我的安装代码:

static install = async ({ code, id }) => {
     const oauthAuth = `Basic ${Buffer
       .from(`${clientId}:${clientSecret}`)
       .toString('base64')}`;
     const redirectUrl = encodeURIComponent(`${url + oauthRedirect}/${id || 'new/zoom'}`);
     const data = `code=${code}&grant_type=authorization_code&redirect_uri=${redirectUrl}`;
     const oauthReq = {
       url: oauth,
       method: 'POST',
       headers: {
         Authorization: oauthAuth,
       },
       data,
     };
     try {
       Logger.info(`Zoom called with code: ${code}`);
       const tokens = await sendRequest(oauthReq);
       const {
         access_token: accessToken,
         refresh_token: refreshToken,
         expires_in: expiresIn,
         token_type: tokenType,
         scope,
       } = tokens;
       Logger.info(`Zoom oauth responded from code: ${code}`);
       const accessTokenAuth = `Bearer ${tokens.access_token}`;
       const profileReq = {
         url: api + profile,
         method: 'GET',
         headers: {
           Authorization: accessTokenAuth,
         },
       };
       const profileResp = await sendRequest(profileReq);
       Logger.info(`Zoom profile responded from code: ${code}`);
       const { email, account_id: refId } = profileResp;
       const currentDate = new Date();
       currentDate.setSeconds(currentDate.getSeconds() + expiresIn);
       return {
         accessToken: FeedSourceService.tokenCrypt(accessToken, 'encrypt'),
         email,
         isConnected: true,
         isTokenDirty: false,
         tokenExpiresAt: currentDate,
         profile: profileResp,
         refId,
         refreshToken: FeedSourceService.tokenCrypt(refreshToken, 'encrypt'),
         scope,
         tokenType,
       };
     } catch (e) {
       Logger.error(`Zoom exception, endpoint: ${oauth}, data: ${data} with error: ${e.message}`);
       e.status = 502; // bad gateway
       e.message = 'Error while connect to Zoom';
       throw e;
     }
   }

谁能帮忙?

【问题讨论】:

    标签: node.js zoom-sdk


    【解决方案1】:

    据 Zoom 开发者论坛 Zoom API 技术支持的一位人士说:
    “对于这里的延迟,我深表歉意,授权码将在 5 分钟后过期,这就是为什么您在延迟 10 分钟后看到此问题的原因。

    如果有帮助,请告诉我。

    谢谢, 最大”

    https://devforum.zoom.us/t/node-js-zoom-api-invalid-authorization-code/55937/4
    这就是解释我的问题。当用户重定向回我的网站时,我最终更改了逻辑以立即获取令牌。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-31
      • 2015-01-19
      • 2013-04-06
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多