Fix MS Teams missing refresh token (#4910)

chore/updating-api-submodule^2
Joe Au-Yeung 2022-10-07 13:59:58 -04:00 committed by GitHub
parent fd12fcc4b8
commit 50ac5f2892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

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 = "";

View File

@ -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 = "";

View File

@ -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;