Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/probot/github-app
node module to handle authentication for the GitHub Apps API
https://github.com/probot/github-app
github github-api github-app
Last synced: about 2 months ago
JSON representation
node module to handle authentication for the GitHub Apps API
- Host: GitHub
- URL: https://github.com/probot/github-app
- Owner: probot
- Archived: true
- Created: 2017-02-26T16:18:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-13T17:15:00.000Z (about 5 years ago)
- Last Synced: 2024-09-22T12:32:55.971Z (about 2 months ago)
- Topics: github, github-api, github-app
- Language: JavaScript
- Homepage:
- Size: 60.5 KB
- Stars: 51
- Watchers: 4
- Forks: 19
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
Replaced by [`@octokit/auth-app`](https://github.com/octokit/auth-app.js/)
# GitHub Apps
NodeJS module for building [GitHub Apps](https://developer.github.com/apps/).
## Installation
```
npm install --save github-app
```## Usage
```js
const createApp = require('github-app');const app = createApp({
// Your app id
id: 987,
// The private key for your app, which can be downloaded from the
// app's settings: https://github.com/settings/apps
cert: require('fs').readFileSync('private-key.pem')
});
```### `asInstallation`
Authenticate [as an installation](https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/about-authentication-options-for-github-apps/#authenticating-as-an-installation), returning a [github API client](https://github.com/mikedeboer/node-github), which can be used to call any of the [APIs supported by GitHub Apps](https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/about-authentication-options-for-github-apps/#authenticating-as-an-installation):
```js
//Modify value according to getInstallations return(example in asApp section)
var installationId = 99999;app.asInstallation(installationId).then(github => {
github.issues.createComment({
owner: 'foo',
repo: 'bar',
number: 999,
body: 'hello world!'
});
});
```### `asApp`
Authenticate [as an app](https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/about-authentication-options-for-github-apps/#authenticating-as-a-github-app), also returning an instance of the GitHub API client.
```js
app.asApp().then(github => {
console.log("Installations:")
github.apps.getInstallations({}).then(console.log);
});
```