Comments (1)
To resolve the issue where the Webex app leads to an empty page after logging in, displaying only an empty JSON object, you should check the handler
function in your Webex API callback implementation. This function processes the response from the Webex API and handles various scenarios, including errors and empty responses.
Here is the relevant part of the code:
import type { NextApiRequest, NextApiResponse } from "next";
import { WEBAPP_URL } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
import createOAuthAppCredential from "../../_utils/oauth/createOAuthAppCredential";
import config from "../config.json";
import { getWebexAppKeys } from "../lib/getWebexAppKeys";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { code } = req.query;
const { client_id, client_secret } = await getWebexAppKeys();
/** @link https://developer.webex.com/docs/integrations#getting-an-access-token **/
const redirectUri = encodeURI(`${WEBAPP_URL}/api/integrations/${config.slug}/callback`);
const authHeader = `Basic ${Buffer.from(`${client_id}:${client_secret}`).toString("base64")}`;
const result = await fetch(
`https://webexapis.com/v1/access_token?grant_type=authorization_code&client_id=${client_id}&client_secret=${client_secret}&code=${code}&redirect_uri=${redirectUri}`,
{
method: "POST",
headers: {
Authorization: authHeader,
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
if (result.status !== 200) {
let errorMessage = "Something is wrong with Webex API";
try {
const responseBody = await result.json();
errorMessage = responseBody.error;
} catch (e) {}
res.status(400).json({ message: errorMessage });
return;
}
const responseBody = await result.json();
if (responseBody.error) {
res.status(400).json({ message: responseBody.error });
return;
}
responseBody.expiry_date = Math.round(Date.now() + responseBody.expires_in * 1000);
delete responseBody.expires_in;
const userId = req.session?.user.id;
if (!userId) {
return res.status(404).json({ message: "No user found" });
}
/**
* With this we take care of no duplicate webex key for a single user
* when creating a video room we only do findFirst so the if they have more than 1
* others get ignored
* */
const existingCredentialWebexVideo = await prisma.credential.findMany({
select: {
id: true,
},
where: {
type: config.type,
userId: req.session?.user.id,
appId: config.slug,
},
});
// Making sure we only delete webex_video
const credentialIdsToDelete = existingCredentialWebexVideo.map((item) => item.id);
if (credentialIdsToDelete.length > 0) {
await prisma.credential.deleteMany({ where: { id: { in: credentialIdsToDelete }, userId } });
}
await createOAuthAppCredential({ appId: config.slug, type: config.type }, responseBody, req);
res.redirect(getInstalledAppPath({ variant: config.variant, slug: config.slug }));
}
To debug and resolve this issue, you can add additional logging or checks to ensure that the response body is correctly handled and not empty. For example, you can add a check to log the response body if it is empty:
const responseBody = await result.json();
if (Object.keys(responseBody).length === 0) {
console.error("Empty response body:", responseBody);
res.status(400).json({ message: "Received empty response body from Webex API" });
return;
}
if (responseBody.error) {
res.status(400).json({ message: responseBody.error });
return;
}
This will help you identify if the response body is indeed empty and provide more information for debugging [1].
To continue talking to Dosu, mention @dosu.
from cal.com.
Related Issues (20)
- fix(ally): unsemantic `button`
- API Error : Failed to proxy http://localhost:5555/api/v2/me Error: connect ECONNREFUSED 127.0.0.1:5555 HOT 1
- [CAL-4314] Issue reassigning members in round robin.
- [CAL-4315] The booking page does not display location icons when there is more than one location. HOT 1
- [CAL-4317] Required multi-select questions become not required after selecting an option and then deleting this option.
- [CAL-4319] Issue with zoom meetings getting "invalid Meeting ID"
- [CAL-4326] Issue with cal dav integration and MAILO
- Ability to set `completedOnboarding` on User creation and edit via API
- [CAL-4328] Instant meeting improvement
- Allow browser notifications button looks bad on mobile HOT 1
- Option to add unconfirmed bookings to calendar
- Access blocked: This app’s request is invalid HOT 1
- track cookie in US but require consent in Europe
- Embed in Webflow - Embeds hidden when more than one are on the page
- Disable input if the URL identifier is prefilled not working on prefilled embeds
- UI Bug: Feedback Button Overlapping App Bar Menu on Mobile Screens HOT 3
- UI accessibility bug HOT 12
- Missing Notifications for Events
- UI Bug: Adding events to - label in the setting/calendar page is overflowing in mobile view
- Cannot read properties of undefined (reading 'ReactCurrentDispatcher') HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cal.com.