Skip to content

Commit

Permalink
feat(integration): support google sheet OAuth (#1624)
Browse files Browse the repository at this point in the history
Because

- support google sheet OAuth

This commit

- support google sheet OAuth
  • Loading branch information
EiffelFly authored Nov 27, 2024
1 parent 8bd46fc commit d4c56a1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/toolkit/src/lib/integrations/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const googleDriveScopes = [
"https://www.googleapis.com/auth/userinfo.profile",
];

const googleSheetsScopes = [
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
];

const githubScopes = ["repo", "write:repo_hook", "user:email", "read:user"];

export function getAuthHandler({
Expand Down Expand Up @@ -91,6 +97,22 @@ export function getAuthHandler({
},
},
}),
GoogleProvider({
id: "google-sheet",
clientId: String(process.env.INTEGRATION_GOOGLE_SHEET_CLIENT_ID),
clientSecret: String(
process.env.INTEGRATION_GOOGLE_SHEET_CLIENT_SECRET,
),
authorization: {
url: "https://accounts.google.com/o/oauth2/auth",
params: {
scope: googleSheetsScopes.join(" "),
prompt: "consent",
access_type: "offline",
response_type: "code",
},
},
}),
GitHubProvider({
clientId: String(process.env.INTEGRATION_GITHUB_CLIENT_ID),
clientSecret: String(process.env.INTEGRATION_GITHUB_CLIENT_SECRET),
Expand Down
6 changes: 5 additions & 1 deletion packages/toolkit/src/lib/integrations/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ export type OnOAuthCallbackProps = {

export type OnOAuthCallback = (props: OnOAuthCallbackProps) => void;

export type IntegrationProvider = "google-drive" | "slack" | "github";
export type IntegrationProvider =
| "google-drive"
| "google-sheet"
| "slack"
| "github";
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export const ConnectableIntegration = ({
case "google-drive":
provider = "google-drive";
break;
case "google-sheet":
provider = "google-sheet";
break;
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +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_GITHUB_CLIENT_ID",
"INTEGRATION_GITHUB_CLIENT_SECRET",
"INTEGRATION_SLACK_CLIENT_ID",
Expand Down

0 comments on commit d4c56a1

Please sign in to comment.