Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(server): Add Google Sheets Integration #7521

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

Torantulino
Copy link
Member

@Torantulino Torantulino commented Jul 20, 2024

This change adds a Google Sheets Integration using a OAuth2 Google Sign-in flow.|

This is a primitive implementation for now, with the authorisation token living purely on the block itself and not being saved elsewhere in the backend, but it works!

  • Reader MVP
  • Writer MVP
  • Read range
  • Read single row
  • Append single row
  • OAuth2 Sign-in with Google
  • Read from URL rather than Spreadsheet ID
  • Add tests

Nice to haves / Future:

  • Persistent Sign-in Cookie?
  • Click sign-in once to be signed into all blocks
  • Overwrite single row?
  • Overwrite range?

image

Update customnode.css and layout.tsx for Google Sign-In integration

This commit adds styles to customnode.css to accommodate the Google Sign-In button. It also updates layout.tsx to wrap the entire application in the GoogleOAuthProvider component, enabling Google Sign-In functionality.
Copy link

netlify bot commented Jul 20, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit a42ef76
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/669d6cab0a39b50008b9c577

This commit renames the `GoogleSheetsBlock` class to `GoogleSheetsReader` in the `google-sheets-block.py` file. The purpose of this change is to provide a more accurate and descriptive name for the block, reflecting its role as a reader for Google Sheets data.
This commit adds the `NEXT_PUBLIC_GOOGLE_CLIENT_ID` variable to the `.env.example` file in the `autogpt_builder` directory. The purpose of this change is to provide a placeholder for the Google client ID that will be used for authentication in the application.
This commit adds the GoogleSheetsWriter block to the google-sheets-block.py file. The purpose of this change is to provide a block that allows writing data to a specified Google Sheet. The block takes inputs such as the spreadsheet ID, sheet name, row data, and access token, and appends the data as a single row to the specified sheet. The result of the append operation is returned as the output of the block.
…gn-In button

The CustomNode component in CustomNode.tsx has been updated to conditionally show the Google Sign-In button based on the block type. Previously, the button was only shown for the 'GoogleSheetsBlock' type, but now it will be shown for any block type that includes 'Google' in its name. This change improves the flexibility and usability of the component.
The GoogleSignInButton component in GoogleSignInButton.tsx has been updated to use the correct Google Sheets scope for authentication. Previously, it was using 'https://www.googleapis.com/auth/spreadsheets.readonly', but now it uses 'https://www.googleapis.com/auth/spreadsheets'. This change ensures that the component has the necessary permissions to interact with Google Sheets.
yield "data", {"error": "No data found."}
else:
data = [row for row in values[0:]]
yield "rows", data
Copy link
Member

Choose a reason for hiding this comment

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

You could yield one row at a time similar to the csv one

Copy link
Member Author

Choose a reason for hiding this comment

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

What CSV one?

Copy link
Member

Choose a reason for hiding this comment

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

I had opened a pr for a csv reader

Copy link
Member

Choose a reason for hiding this comment

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

result = sheet.values().get(spreadsheetId=input_data.spreadsheet_id, range=input_data.range).execute()
values = result.get("values", [])

if not values:
Copy link
Member

Choose a reason for hiding this comment

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

Probably yield error, message

This change allows the user to specify a single row to be read from a spreadsheet, rather than reading the entire thing or a specified range.
Previously, the user would have to manually extract and input their speadsheet ID from the URL. This change makes it so that the user just has to input the URL.
@Torantulino
Copy link
Member Author

Torantulino commented Jul 21, 2024

I can't for the life of me get test mocking to work on a block like this.

@majdyz, can you show me how?

@Torantulino Torantulino added the Block A Block to be used in the AutoGPT Builder label Jul 21, 2024
@Torantulino Torantulino marked this pull request as ready for review July 21, 2024 19:23
@ntindle ntindle self-assigned this Jul 22, 2024
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Jul 23, 2024
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@ntindle ntindle removed their assignment Jul 24, 2024
@Pwuts Pwuts marked this pull request as draft August 21, 2024 10:14
@Pwuts
Copy link
Member

Pwuts commented Aug 21, 2024

Will fix up this PR and merge it once we have finished implementing initial OAuth support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Block A Block to be used in the AutoGPT Builder Builder AutoGPT Builder conflicts Automatically applied to PRs with merge conflicts Server size/l
Projects
Status: 🆕 Needs initial review
Development

Successfully merging this pull request may close these issues.

3 participants