Skip to content

Microsoft OAuth

JsWorkflows provides a platform-managed Microsoft OAuth app — you do not need to register an Azure application or provide credentials.

ResourceOperationScope
Outlook MailRead mailMail.Read
Outlook MailSend mailMail.Send
Outlook MailRead & write mailMail.ReadWrite, Mail.Send
OneDriveRead filesFiles.Read
OneDriveRead & write filesFiles.ReadWrite
Outlook CalendarRead calendarCalendars.Read
Outlook CalendarRead & write calendarCalendars.ReadWrite
Outlook ContactsRead contactsContacts.Read
Outlook ContactsRead & write contactsContacts.ReadWrite
User ProfileRead profileUser.Read
  1. Go to OAuth Connections → Add Connection → Microsoft.
  2. Select the resources and operations your workflow needs.
  3. Sign in with your Microsoft account and grant the requested permissions.
  4. Give the connection a handle (e.g., my-microsoft).

Access tokens are refreshed automatically when they expire.

class Workflow {
async start(data, headers, api) {
const { token, error } = await api.getOAuthToken('my-microsoft');
if (error) { api.log('OAuth error:', error); return; }
await fetch('https://graph.microsoft.com/v1.0/me/sendMail', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
},
body: JSON.stringify({
message: {
subject: `Order ${data.name} confirmed`,
body: { contentType: 'Text', content: `Thank you for your order of ${data.total_price} ${data.currency}.` },
toRecipients: [{ emailAddress: { address: data.email } }],
},
}),
});
}
}
const { token } = await api.getOAuthToken('my-microsoft');
await fetch('https://graph.microsoft.com/v1.0/me/drive/root:/reports/orders.csv:/content', {
method: 'PUT',
headers: {
'Content-Type': 'text/csv',
'Authorization': `Bearer ${token}`,
},
body: csvString,
});