48 lines
1.5 KiB
Markdown
48 lines
1.5 KiB
Markdown
# Google API Integration
|
|
|
|
This directory contains unified endpoints for Google API integration, all protected under the `/private` route to ensure only authenticated users can access them.
|
|
|
|
## Auth Endpoints
|
|
|
|
### `/private/api/google/auth/refresh`
|
|
|
|
- **Method**: POST
|
|
- **Purpose**: Refreshes an access token using a refresh token
|
|
- **Body**: `{ "refreshToken": "your-refresh-token" }`
|
|
- **Response**: `{ "accessToken": "new-access-token", "expiresIn": 3600 }`
|
|
|
|
### `/private/api/google/auth/userinfo`
|
|
|
|
- **Method**: GET
|
|
- **Purpose**: Gets information about the authenticated user
|
|
- **Headers**: Authorization: Bearer `access_token`
|
|
- **Response**: `{ "email": "user@example.com", "name": "User Name", "picture": "profile-pic-url" }`
|
|
|
|
### `/private/api/google/auth/revoke`
|
|
|
|
- **Method**: POST
|
|
- **Purpose**: Revokes an access token
|
|
- **Body**: `{ "accessToken": "token-to-revoke" }`
|
|
- **Response**: `{ "success": true }`
|
|
|
|
## Sheets Endpoints
|
|
|
|
### `/private/api/google/sheets/recent`
|
|
|
|
- **Method**: GET
|
|
- **Purpose**: Gets a list of recent spreadsheets
|
|
- **Headers**: Authorization: Bearer `refresh_token`
|
|
- **Response**: Array of spreadsheet objects
|
|
|
|
### `/private/api/google/sheets/[sheetId]/data`
|
|
|
|
- **Method**: GET
|
|
- **Purpose**: Gets data from a specific spreadsheet
|
|
- **Headers**: Authorization: Bearer `refresh_token`
|
|
- **URL Parameters**: sheetId - The ID of the spreadsheet
|
|
- **Response**: Spreadsheet data including values array
|
|
|
|
## Client Usage
|
|
|
|
Use the utility functions in `$lib/google.ts` to interact with these endpoints.
|