Skip to content

Commit

Permalink
refactor: πŸ”’οΈ Still investigating sheets creds issue
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Apr 21, 2022
1 parent 2dc0e45 commit 606932a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions apps/builder/pages/api/integrations/google-sheets/spreadsheets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { drive } from '@googleapis/drive'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { badRequest, methodNotAllowed, notAuthenticated } from 'utils'
import { setUser, withSentry } from '@sentry/nextjs'
import {
badRequest,
forbidden,
methodNotAllowed,
notAuthenticated,
} from 'utils'
import { captureException, setUser, withSentry } from '@sentry/nextjs'
import { getAuthenticatedUser } from 'services/api/utils'

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
Expand All @@ -16,7 +21,15 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const auth = await getAuthenticatedGoogleClient(user.id, credentialsId)
if (!auth)
return res.status(404).send("Couldn't find credentials in database")
console.log(auth.credentials.name, user.email)
if (auth.credentials.ownerId !== user.id) {
// It should never happen but for some reason it does in rare cases... Currently under investigation.
captureException(
new Error(
`Credentials ownerId does not match user id ${auth.credentials.ownerId} !== ${user.id}`
)
)
return forbidden(res)
}
const response = await drive({
version: 'v3',
auth: auth.client,
Expand Down

4 comments on commit 606932a

@vercel
Copy link

@vercel vercel bot commented on 606932a Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 606932a Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

landing-page-v2 – ./apps/landing-page

typebot.io
www.typebot.io
get-typebot.com
landing-page-v2-typebot-io.vercel.app
landing-page-v2-git-main-typebot-io.vercel.app
www.get-typebot.com

@vercel
Copy link

@vercel vercel bot commented on 606932a Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.