Skip to content

Google OAuth

JsWorkflows provides a platform-managed Google OAuth app — you do not need to create a Google Cloud project or provide credentials.

ResourceOperationScope
Google SheetsRead spreadsheetspreadsheets.readonly
Google SheetsWrite spreadsheetspreadsheets
Google DriveUpload filesdrive.file
GmailSend emailgmail.send
Google CalendarRead eventscalendar.readonly
Google CalendarCreate/update eventscalendar.events
Google DocsRead documentsdocuments.readonly
Google DocsEdit documentsdocuments
  1. Go to OAuth Connections → Add Connection → Google.
  2. Select the resources and operations your workflow needs.
  3. Sign in with your Google account and grant the requested permissions.
  4. Give the connection a handle (e.g., my-google).
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()]]
}),
}
);
}
}
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 }),
});