Skip to content

Add Google Sheets service - #18

Merged
TejaBudumuru3 merged 1 commit into
mainfrom
google-sheets-node
Nov 25, 2025
Merged

Add Google Sheets service#18
TejaBudumuru3 merged 1 commit into
mainfrom
google-sheets-node

Conversation

@TejaBudumuru3

@TejaBudumuru3 TejaBudumuru3 commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Integrated Google Sheets support with OAuth2 authentication for secure data access
    • Users can now read and retrieve data from specific spreadsheet ranges
  • Chores

    • Established package infrastructure and added authentication helper utilities for Google Sheets setup

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 25, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces Google Sheets API integration to the packages/nodes project. It adds a GoogleSheetsService class with OAuth2 authentication, utility scripts for token generation and authorization, a test/demo script, and supporting configuration files. The .gitignore is updated to exclude generated token files.

Changes

Cohort / File(s) Summary
Configuration & Package Setup
.gitignore, packages/nodes/package.json
Updated .gitignore to exclude generated token files and Google client credentials. New package.json defines "nodes" package with dependencies on dotenv, google-auth-library, googleapis, and @types/node devDependency.
Google Sheets Service
packages/nodes/src/google-sheets/google-sheets.service.ts
Introduces GoogleSheetsService class with OAuth2 authentication initialization from environment variables. Implements readRows() method to fetch spreadsheet values. Exports GoogleSheetsCredentials and ReadRowsParams interfaces for type safety.
OAuth2 Utilities
packages/nodes/src/google-sheets/repl.js, packages/nodes/src/google-sheets/token.js
repl.js generates authorization URL for offline Google Sheets access. token.js exchanges authorization code for access/refresh tokens via OAuth2 flow. Both configure client from environment credentials.
Test & Demo
packages/nodes/src/google-sheets/test.ts
Demonstration script that loads .env, instantiates GoogleSheetsService with hardcoded credentials, and invokes readRows() to fetch and display spreadsheet data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant repl.js as repl.js<br/>(Auth URL Gen)
    participant Browser
    participant GoogleAuth as Google OAuth2
    participant token.js as token.js<br/>(Token Exchange)
    
    User->>repl.js: npm run repl
    repl.js->>GoogleAuth: generateAuthUrl(offline, sheets scope)
    GoogleAuth-->>repl.js: auth URL
    repl.js-->>User: Display URL + visit prompt
    User->>Browser: Visit auth URL
    Browser->>GoogleAuth: Authorize access
    GoogleAuth-->>Browser: Return code in redirect
    User->>token.js: npm run token (with code)
    token.js->>GoogleAuth: exchangeCodeForToken(code)
    GoogleAuth-->>token.js: {access_token, refresh_token, expiry_date}
    token.js-->>User: Display tokens
Loading
sequenceDiagram
    participant test.ts as test.ts<br/>(Test Script)
    participant Service as GoogleSheetsService
    participant GoogleAPI as Google Sheets API
    
    test.ts->>test.ts: Load credentials from env/.hardcoded
    test.ts->>Service: new GoogleSheetsService(credentials)
    Service->>Service: Initialize OAuth2 client<br/>with credentials
    Service->>GoogleAPI: Create sheets client
    test.ts->>Service: readRows({spreadsheetId, range})
    Service->>GoogleAPI: sheets.spreadsheets.values.get()
    GoogleAPI-->>Service: {values: [[...],...]}
    Service-->>test.ts: Return row values
    test.ts-->>test.ts: Log results or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • OAuth2 credential management: Verify environment variable usage and credential passing across files (repl.js, token.js, google-sheets.service.ts)
  • API authentication flow: Ensure OAuth2 client initialization and credential application are correct in the service
  • Error handling: Check error handling in readRows() and token exchange operations
  • Test credentials: Verify that hardcoded test credentials in test.ts are appropriate and will not expose sensitive data

Poem

🐰 A service so fine, sheets aligned,
OAuth tokens gracefully signed,
Spreadsheets now dance at your command,
Integration across the land!
Hop along to rows anew,
What spreadsheet magic awaits you? 📊

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch google-sheets-node

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83611ea and 161f2d5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • .gitignore (1 hunks)
  • packages/nodes/package.json (1 hunks)
  • packages/nodes/src/google-sheets/google-sheets.service.ts (1 hunks)
  • packages/nodes/src/google-sheets/repl.js (1 hunks)
  • packages/nodes/src/google-sheets/test.ts (1 hunks)
  • packages/nodes/src/google-sheets/token.js (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@TejaBudumuru3
TejaBudumuru3 merged commit 2a75f93 into main Nov 25, 2025
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant