chore: enable platform emails (#14471)
* feat: enable platform emails * fixup! feat: enable platform emails * fixup! fixup! feat: enable platform emails * fixup! Merge branch 'main' into chore-platform-emails * fixup! fixup! Merge branch 'main' into chore-platform-emails * fixup! fixup! fixup! Merge branch 'main' into chore-platform-emails * chore: add oauth client repo * chore: enable platform emails using oauth client * fix: call getConnectedCalendar with dbWrite since it creates destinationCalendar for new credentials * chore: update doc * fixup! chore: update doc * fixup! fixup! chore: update doc
This commit is contained in:
1 parent
19d938ed60
commit
e641bb3d57
18 files changed
+442
-142
No files matched your search
@@ -30,13 +30,17 @@ export const useOAuthClient = ({ clientId, apiUrl, refreshUrl, onError, onSucces
|
||||
useEffect(() => {
|
||||
if (clientId && http.getUrl() && prevClientId !== clientId) {
|
||||
try {
|
||||
http.get<ApiResponse>(`/ee/provider/${clientId}`).catch((err: AxiosError) => {
|
||||
if (err.response?.status === 401) {
|
||||
onError("Invalid oAuth Client.");
|
||||
} else {
|
||||
http
|
||||
.get<ApiResponse>(`/ee/provider/${clientId}`)
|
||||
.then(() => {
|
||||
onSuccess();
|
||||
}
|
||||
});
|
||||
http.setClientIdHeader(clientId);
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
if (err.response?.status === 401) {
|
||||
onError("Invalid oAuth Client.");
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@ const http = (function () {
|
||||
getAuthorizationHeader: () => {
|
||||
return instance.defaults.headers.common?.["Authorization"]?.toString() ?? "";
|
||||
},
|
||||
setClientIdHeader: (clientId: string) => {
|
||||
instance.defaults.headers.common["x-cal-client-id"] = clientId;
|
||||
},
|
||||
getClientIdHeader: () => {
|
||||
return instance.defaults.headers.common?.["x-cal-client-id"]?.toString() ?? "";
|
||||
},
|
||||
refreshTokens: async (refreshUrl: string): Promise<string> => {
|
||||
const response = await fetch(`${refreshUrl}`, {
|
||||
method: "GET",
|
||||
|
||||
@@ -46,6 +46,7 @@ export const API_ERROR_CODES = [
|
||||
|
||||
// Request headers
|
||||
export const X_CAL_SECRET_KEY = "x-cal-secret-key";
|
||||
export const X_CAL_CLIENT_ID = "x-cal-client-id";
|
||||
|
||||
// HTTP status codes
|
||||
export const HTTP_CODE_TOKEN_EXPIRED = 498;
|
||||
Reference in new issue
Block a user