Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created November 17, 2024 13:58
Show Gist options
  • Save thekarel/f4926366bb7cdd20972cb0062cf018de to your computer and use it in GitHub Desktop.
Save thekarel/f4926366bb7cdd20972cb0062cf018de to your computer and use it in GitHub Desktop.
Revoke a GitHub Oauth app grant via REST
// This will remove the grant, i.e. as if the user never registered with the app.
// They will have to go trough the consent screen again
await ky
.delete(`https://api.github.com/applications/${event.locals.env.AUTH_GITHUB_ID}/grant`, {
headers: {
Accept: 'application/vnd.github+json',
Authorization: `Basic ${btoa(`${event.locals.env.AUTH_GITHUB_ID}:${event.locals.env.AUTH_GITHUB_SECRET}`)}`,
'X-GitHub-Api-Version': '2022-11-28',
},
json: {
access_token: session.user.accessToken,
},
})
.catch((error) => {
console.error('error in github grant delete', error)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment