Fix Google Drive Connector when using OAuth

This commit is contained in:
Weves
2023-10-14 23:34:04 -07:00
committed by Chris Weaver
parent 38d516cc7a
commit ae0dbfadc6
3 changed files with 7 additions and 9 deletions

View File

@@ -400,7 +400,7 @@ export const DriveOAuthSection = ({
<Button <Button
onClick={async () => { onClick={async () => {
const [authUrl, errorMsg] = await setupGoogleDriveOAuth({ const [authUrl, errorMsg] = await setupGoogleDriveOAuth({
isPublic: true, isAdmin: true,
}); });
if (authUrl) { if (authUrl) {
// cookie used by callback to determine where to finally redirect to // cookie used by callback to determine where to finally redirect to

View File

@@ -114,7 +114,7 @@ export const GoogleDriveCard = ({
<Button <Button
onClick={async () => { onClick={async () => {
const [authUrl, errorMsg] = await setupGoogleDriveOAuth({ const [authUrl, errorMsg] = await setupGoogleDriveOAuth({
isPublic: false, isAdmin: false,
}); });
if (authUrl) { if (authUrl) {
// cookie used by callback to determine where to finally redirect to // cookie used by callback to determine where to finally redirect to

View File

@@ -1,19 +1,17 @@
import { Credential } from "@/lib/types"; import { Credential } from "@/lib/types";
interface SetupGoogleDriveArgs {
isPublic: boolean;
}
export const setupGoogleDriveOAuth = async ({ export const setupGoogleDriveOAuth = async ({
isPublic, isAdmin,
}: SetupGoogleDriveArgs): Promise<[string | null, string]> => { }: {
isAdmin: boolean;
}): Promise<[string | null, string]> => {
const credentialCreationResponse = await fetch("/api/manage/credential", { const credentialCreationResponse = await fetch("/api/manage/credential", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify({ body: JSON.stringify({
public_doc: isPublic, is_admin: isAdmin,
credential_json: {}, credential_json: {},
}), }),
}); });