Google OAuth
JsWorkflows provides a platform-managed Google OAuth app — you do not need to create a Google Cloud project or provide credentials.
Available scopes
Section titled “Available scopes”| Resource | Operation | Scope |
|---|---|---|
| Google Sheets | Read spreadsheet | spreadsheets.readonly |
| Google Sheets | Write spreadsheet | spreadsheets |
| Google Drive | Upload files | drive.file |
| Gmail | Send email | gmail.send |
| Google Calendar | Read events | calendar.readonly |
| Google Calendar | Create/update events | calendar.events |
| Google Docs | Read documents | documents.readonly |
| Google Docs | Edit documents | documents |
Connecting
Section titled “Connecting”- Go to OAuth Connections → Add Connection → Google.
- Select the resources and operations your workflow needs.
- Sign in with your Google account and grant the requested permissions.
- Give the connection a handle (e.g.,
my-google).
Example — append a row to Google Sheets
Section titled “Example — append a row to Google Sheets”class Workflow { async start(data, headers, api) { // data IS the order object for orders/* webhook topics const { token } = await api.getOAuthToken('my-google');
await fetch( 'https://sheets.googleapis.com/v4/spreadsheets/{SPREADSHEET_ID}/values/Sheet1!A1:append?valueInputOption=USER_ENTERED', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}`, }, body: JSON.stringify({ values: [[data.id, data.total_price, data.email, new Date().toISOString()]] }), } ); }}Example — send a Gmail message
Section titled “Example — send a Gmail message”const { token } = await api.getOAuthToken('my-google');const raw = btoa(`To: customer@example.com\r\nSubject: Your order\r\n\r\nThank you!`);await fetch('https://gmail.googleapis.com/gmail/v1/users/me/messages/send', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}`, }, body: JSON.stringify({ raw }),});