mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-13 21:29:31 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { useEffect } from "react";
|
|
import { useRouter } from "next/router";
|
|
import queryString from "query-string";
|
|
|
|
import {
|
|
useAuthorizeIntegration
|
|
} from "@app/hooks/api";
|
|
|
|
export default function GCPSecretManagerOAuth2CallbackPage() {
|
|
const router = useRouter();
|
|
const { mutateAsync } = useAuthorizeIntegration();
|
|
|
|
const { code, state } = queryString.parse(router.asPath.split("?")[1]);
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
try {
|
|
// validate state
|
|
|
|
if (state !== localStorage.getItem("latestCSRFToken")) return;
|
|
localStorage.removeItem("latestCSRFToken");
|
|
const integrationAuth = await mutateAsync({
|
|
workspaceId: localStorage.getItem("projectData.id") as string,
|
|
code: code as string,
|
|
integration: "gcp-secret-manager"
|
|
});
|
|
|
|
router.push(`/integrations/gcp-secret-manager/create?integrationAuthId=${integrationAuth.id}`);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
})();
|
|
}, []);
|
|
|
|
return <div />;
|
|
}
|
|
|
|
GCPSecretManagerOAuth2CallbackPage.requireAuth = true;
|