【发布时间】: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;
}
}
谁能帮忙?
【问题讨论】: