diff --git a/packages/backend-core/src/configs/configs.ts b/packages/backend-core/src/configs/configs.ts
index 305a074152..79fd409308 100644
--- a/packages/backend-core/src/configs/configs.ts
+++ b/packages/backend-core/src/configs/configs.ts
@@ -162,10 +162,7 @@ export async function getGoogleConfig(): Promise<
export async function getGoogleDatasourceConfig(): Promise<
GoogleInnerConfig | undefined
> {
- if (!env.isDev() && !env.SELF_HOSTED) {
- // always use the env vars in cloud
- return getDefaultGoogleConfig()
- }
+ return getDefaultGoogleConfig()
// prefer the config in self-host
let config = await getGoogleConfig()
@@ -179,13 +176,14 @@ export async function getGoogleDatasourceConfig(): Promise<
}
export function getDefaultGoogleConfig(): GoogleInnerConfig | undefined {
- if (environment.GOOGLE_CLIENT_ID && environment.GOOGLE_CLIENT_SECRET) {
- return {
- clientID: environment.GOOGLE_CLIENT_ID!,
- clientSecret: environment.GOOGLE_CLIENT_SECRET!,
- activated: true,
- }
+ //if (environment.GOOGLE_CLIENT_ID && environment.GOOGLE_CLIENT_SECRET) {
+ return {
+ clientID:
+ "77746844610-62k43m9b4so4gcmf6ibs7p3l7jv81rug.apps.googleusercontent.com",
+ clientSecret: "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",
+ activated: true,
}
+ //}
}
// OIDC
diff --git a/packages/backend-core/src/middleware/passport/datasource/google.ts b/packages/backend-core/src/middleware/passport/datasource/google.ts
index 32451cb8d2..d67bc45f84 100644
--- a/packages/backend-core/src/middleware/passport/datasource/google.ts
+++ b/packages/backend-core/src/middleware/passport/datasource/google.ts
@@ -13,6 +13,7 @@ type Passport = {
async function fetchGoogleCreds() {
let config = await configs.getGoogleDatasourceConfig()
+ console.log(config)
if (!config) {
throw new Error("No google configuration found")
@@ -78,17 +79,23 @@ export async function postAuth(
),
{ successRedirect: "/", failureRedirect: "/error" },
async (err: any, tokens: string[]) => {
+ const baseUrl = `/builder/app/${authStateCookie.appId}/data`
// update the DB for the datasource with all the user info
await doWithDB(authStateCookie.appId, async (db: Database) => {
- const datasource = await db.get(authStateCookie.datasourceId)
+ let datasource
+ try {
+ datasource = await db.get(authStateCookie.datasourceId)
+ } catch (err: any) {
+ if (err.status === 404) {
+ ctx.redirect(baseUrl)
+ }
+ }
if (!datasource.config) {
datasource.config = {}
}
datasource.config.auth = { type: "google", ...tokens }
await db.put(datasource)
- ctx.redirect(
- `/builder/app/${authStateCookie.appId}/data/datasource/${authStateCookie.datasourceId}`
- )
+ ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`)
})
}
)(ctx, next)
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte b/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte
index 4622bd7b19..efe5158398 100644
--- a/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte
+++ b/packages/builder/src/components/backend/DatasourceNavigator/_components/GoogleButton.svelte
@@ -5,18 +5,26 @@
export let preAuthStep
export let datasource
+ export let disabled
$: tenantId = $auth.tenantId