Fix MS Teams missing refresh token (#4910)

This commit is contained in:
Joe Au-Yeung authored and GitHub committed 2022-10-07 13:59:58 -04:00
1 parent fd12fcc4b8
commit 50ac5f2892
3 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ import { WEBAPP_URL } from "@calcom/lib/constants";
import { encodeOAuthState } from "../../_utils/encodeOAuthState";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
const scopes = ["OnlineMeetings.ReadWrite"];
const scopes = ["OnlineMeetings.ReadWrite", "offline_access"];
let client_id = "";
@@ -8,7 +8,7 @@ import { decodeOAuthState } from "../../_utils/decodeOAuthState";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
import getInstalledAppPath from "../../_utils/getInstalledAppPath";
const scopes = ["OnlineMeetings.ReadWrite"];
const scopes = ["OnlineMeetings.ReadWrite", "offline_access"];
let client_id = "";
let client_secret = "";
@@ -49,7 +49,6 @@ const o365Auth = async (credential: Credential) => {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
scope: "User.Read OnlineMeetings.ReadWrite",
client_id,
refresh_token: refreshToken,
grant_type: "refresh_token",
@@ -57,6 +56,10 @@ const o365Auth = async (credential: Credential) => {
}),
});
const responseBody = await handleErrorsJson(response);
if (responseBody.error) {
console.error(responseBody);
throw new HttpError({ statusCode: 500, message: "Error contacting MS Teams" });
}
// set expiry date as offset from current time.
responseBody.expiry_date = Math.round(Date.now() + responseBody.expires_in * 1000);
delete responseBody.expires_in;