- Notifications
You must be signed in to change notification settings - Fork110
HTTP Round Tripper for GitHub Apps - Authenticate as an Installation Workflow
License
bradleyfalzon/ghinstallation
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
ghinstallation providesTransport, which implementshttp.RoundTripper toprovide authentication as an installation for GitHub Apps.
This library is designed to provide automatic authentication forhttps://github.com/google/go-github or your own HTTP client.
Get the package:
go get -u github.com/bradleyfalzon/ghinstallation/v2
import"github.com/bradleyfalzon/ghinstallation/v2"funcmain() {// 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")iferr!=nil {log.Fatal(err)}// Use installation transport with github.com/google/go-githubclient:=github.NewClient(&http.Client{Transport:itr})}
You can also useNew() to load a key directly from a[]byte.
For clients using GitHub Enterprise, set the base URL as follows:
import"github.com/bradleyfalzon/ghinstallation/v2"constGitHubEnterpriseURL="https://github.example.com/api/v3"funcmain() {// 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")iferr!=nil {log.Fatal(err)}itr.BaseURL=GitHubEnterpriseURL// Use installation transport with github.com/google/go-githubclient:=github.NewEnterpriseClient(GitHubEnterpriseURL,GitHubEnterpriseURL,&http.Client{Transport:itr})}
app ID is the GitHub App ID.
You can check as following :
Settings > Developer > settings > GitHub App > About item
installation ID is a part of WebHook request.
You can get the number to check the request.
Settings > Developer > settings > GitHub Apps > Advanced > Payload in Requesttab
WebHook request... "installation": { "id": `installation ID` }Users can customize signing behavior by passing in aSignerimplementation when creating anAppsTransport.For example, this can be used to create tokens backed by keys in a KMS system.
signer:=&myCustomSigner{key:"https://url/to/key/vault",}atr:=NewAppsTransportWithOptions(http.DefaultTransport,1,WithSigner(signer))tr:=NewFromAppsTransport(atr,99)
About
HTTP Round Tripper for GitHub Apps - Authenticate as an Installation Workflow
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.