Skip to content

Commit

Permalink
Add a function to obtain an installation access token
Browse files Browse the repository at this point in the history
When we want to act as the GitHub App, on a specific repository, we need
this access token.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Dec 1, 2022
1 parent 8a941c8 commit a49181e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions GitForWindowsHelper/get-installation-access-token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = async (context, installation_id) => {
const gitHubApiRequestAsApp = require('./github-api-request-as-app')
const answer = await gitHubApiRequestAsApp(
context,
'POST',
`/app/installations/${installation_id}/access_tokens`)
if (answer.error) throw answer.error
if (answer.token) return answer.token
throw new Error(`Unhandled response:\n${JSON.stringify(answer, null, 2)}`)
}

0 comments on commit a49181e

Please sign in to comment.