Skip to content

Commit acca0b6

Browse files
Update README.md with additional auth use case (#2434)
1 parent f2d99f1 commit acca0b6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,34 @@ See the [oauth2 docs][] for complete instructions on using that library.
117117
For API methods that require HTTP Basic Authentication, use the
118118
[`BasicAuthTransport`](https://godoc.org/github.com/google/go-github/github#BasicAuthTransport).
119119

120+
#### As a GitHub App ####
121+
120122
GitHub Apps authentication can be provided by the [ghinstallation](https://github.com/bradleyfalzon/ghinstallation)
121123
package.
122124

125+
> **Note**: Most endpoints (ex. [`GET /rate_limit`]) require access token authentication
126+
> while a few others (ex. [`GET /app/hook/deliverires`]) require [JWT] authentication.
127+
128+
[`GET /rate_limit`]: https://docs.github.com/en/rest/rate-limit#get-rate-limit-status-for-the-authenticated-user
129+
[`GET /app/hook/deliverires`]: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook
130+
[JWT]: https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app
131+
132+
123133
```go
124134
import (
135+
"net/http"
136+
125137
"github.com/bradleyfalzon/ghinstallation/v2"
126138
"github.com/google/go-github/v45/github"
127139
)
128140

129141
func main() {
130142
// Wrap the shared transport for use with the integration ID 1 authenticating with installation ID 99.
131143
itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, 1, 99, "2016-10-19.private-key.pem")
144+
145+
// Or for endpoints that require JWT authentication
146+
// itr, err := ghinstallation.NewAppsTransportKeyFromFile(http.DefaultTransport, 1, "2016-10-19.private-key.pem")
147+
132148
if err != nil {
133149
// Handle error.
134150
}

0 commit comments

Comments
 (0)