Skip to content

Commit

Permalink
Merge pull request bradleyfalzon#26 from bradleyfalzon/ghent-example
Browse files Browse the repository at this point in the history
Update README to include GitHub Enterprise example
  • Loading branch information
bradleyfalzon authored Sep 17, 2019
2 parents 49ae7c5 + 1defb17 commit 7bdf9f8
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ https://github.com/google/go-github or your own HTTP client.
See
https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/about-authentication-options-for-github-apps/

# Example
# Installation

Get the package:

```bash
go get -u github.com/bradleyfalzon/ghinstallation
```

Usage:
# GitHub Example

```go
import "github.com/bradleyfalzon/ghinstallation"
Expand All @@ -39,6 +39,31 @@ func main() {
}
```

# GitHub Enterprise Example

For clients using GitHub Enterprise, set the base URL as follows:

```go
import "github.com/bradleyfalzon/ghinstallation"

const GitHubEnterpriseURL = "https://github.example.com/api/v3"

func main() {
// Shared transport to reuse TCP connections.
tr := http.DefaultTransport

// Wrap the shared transport for use with the app ID 1 authenticating with installation ID 99.
itr, err := ghinstallation.NewKeyFromFile(tr, 1, 99, "2016-10-19.private-key.pem")
if err != nil {
log.Fatal(err)
}
itr.BaseURL = GitHubEnterpriseURL

// Use installation transport with github.com/google/go-github
client := github.NewEnterpriseClient(GitHubEnterpriseURL, GitHubEnterpriseURL, &http.Client{Transport: itr})
}
```

## What is app ID and installation ID

`app ID` is the GitHub App ID. \
Expand Down

0 comments on commit 7bdf9f8

Please sign in to comment.