Skip to content

Commit

Permalink
fix: fix google sheets oauth config (#1625)
Browse files Browse the repository at this point in the history
Because

- google-sheet should be google-sheets

This commit

- fix google sheets oauth config
  • Loading branch information
EiffelFly authored Nov 27, 2024
1 parent d4c56a1 commit 92734df
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
39 changes: 36 additions & 3 deletions packages/toolkit/src/lib/integrations/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export function getAuthHandler({
},
}),
GoogleProvider({
id: "google-sheet",
clientId: String(process.env.INTEGRATION_GOOGLE_SHEET_CLIENT_ID),
id: "google-sheets",
clientId: String(process.env.INTEGRATION_GOOGLE_SHEETS_CLIENT_ID),
clientSecret: String(
process.env.INTEGRATION_GOOGLE_SHEET_CLIENT_SECRET,
process.env.INTEGRATION_GOOGLE_SHEETS_CLIENT_SECRET,
),
authorization: {
url: "https://accounts.google.com/o/oauth2/auth",
Expand Down Expand Up @@ -174,6 +174,39 @@ export function getAuthHandler({
};
break;
}
case "google-sheets": {
const identity = profile.email ?? profile.name;

if (!identity) {
throw new Error(
"Instill Integration Error: Google Sheets user not found, can't get the identity",
);
}

const prefilledIntegrationConnectionId =
getPrefilledOAuthIntegrationConnectionId({
provider: "google-sheets",
connectionIdentity: identity,
});

payload = {
integrationId: "google-sheets",
method: "METHOD_OAUTH",
setup: {
token: account.access_token,
"refresh-token": account.refresh_token,
},
namespaceId,
id: prefilledIntegrationConnectionId,
oAuthAccessDetails: {
...account,
...profile,
},
identity: identity,
scopes: googleDriveScopes,
};
break;
}
case "github": {
const identity = profile.login as string | undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/lib/integrations/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export type OnOAuthCallback = (props: OnOAuthCallbackProps) => void;

export type IntegrationProvider =
| "google-drive"
| "google-sheet"
| "google-sheets"
| "slack"
| "github";
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export const ConnectableIntegration = ({
case "google-drive":
provider = "google-drive";
break;
case "google-sheet":
provider = "google-sheet";
case "google-sheets":
provider = "google-sheets";
break;
default:
break;
Expand Down
4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"INSTILL_API_VERSION",
"INTEGRATION_GOOGLE_DRIVE_CLIENT_ID",
"INTEGRATION_GOOGLE_DRIVE_CLIENT_SECRET",
"INTEGRATION_GOOGLE_SHEET_CLIENT_ID",
"INTEGRATION_GOOGLE_SHEET_CLIENT_SECRET",
"INTEGRATION_GOOGLE_SHEETS_CLIENT_ID",
"INTEGRATION_GOOGLE_SHEETS_CLIENT_SECRET",
"INTEGRATION_GITHUB_CLIENT_ID",
"INTEGRATION_GITHUB_CLIENT_SECRET",
"INTEGRATION_SLACK_CLIENT_ID",
Expand Down

0 comments on commit 92734df

Please sign in to comment.