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
onClick={async () => {
const [authUrl, errorMsg] = await setupGoogleDriveOAuth({
isPublic: true,
isAdmin: true,
});
if (authUrl) {
// cookie used by callback to determine where to finally redirect to

View File

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

View File

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