Skip to content

GitHub OAuth

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

ResourceOperationScope
RepositoriesRead public repositoriespublic_repo
RepositoriesRead/write all repositories (including private)repo
Issues & Pull RequestsCreate/update issues & PRsrepo
GitHub ActionsManage workflow filesworkflow
User ProfileRead user profileread:user
User ProfileRead user emailuser:email
NotificationsRead & manage notificationsnotifications
  1. Go to OAuth Connections → Add Connection → GitHub.
  2. Select the resources and operations your workflow needs.
  3. Sign in with your GitHub account and grant the requested permissions.
  4. Give the connection a handle (e.g., my-github).

GitHub OAuth tokens do not expire and are not automatically refreshed.

class Workflow {
async start(data, headers, api) {
const { token, error } = await api.getOAuthToken('my-github');
if (error) { api.log('OAuth error:', error); return; }
await fetch('https://api.github.com/repos/{owner}/{repo}/issues', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
'Accept': 'application/vnd.github+json',
},
body: JSON.stringify({
title: `Order ${data.name} requires attention`,
body: `Order total: ${data.total_price} ${data.currency}\nCustomer: ${data.email}`,
}),
});
}
}

Example — trigger a GitHub Actions workflow

Section titled “Example — trigger a GitHub Actions workflow”
const { token } = await api.getOAuthToken('my-github');
await fetch('https://api.github.com/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
'Accept': 'application/vnd.github+json',
},
body: JSON.stringify({ ref: 'main' }),
});