You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: change default webhook path to /webhooks/github/
- Update default github_app_route from "/" to "/webhooks/github/"
- Update fallback webhook route defaults in core.py
- Update documentation and code comments to reflect new default
- Update sample configurations and README files for consistency
- Update curl example in main README to use new default path
BREAKING CHANGE: Default webhook path changed from "/" to "/webhooks/github/".
Existing GitHub App webhook URLs need to be updated in GitHub App settings.
Copy file name to clipboardExpand all lines: README.md
+10-15Lines changed: 10 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ The above function will do `stuff here` for _every_ `issues` event received. Thi
40
40
41
41
Inside the function, you can access the received request via the conveniently named `request` variable. You can access its payload by simply getting it: `request.payload`
42
42
43
-
You can find a complete example (containing this cruel_closer function), in the samples folder of this repo. It is a fully functioning FastAPI Github App.
43
+
You can find examples in the samples folder of this repo. The [samples](./samples/) include fully functioning FastAPI GitHub Apps demonstrating different features.
Now, you can send requests! The port is 5005 by default but that can also be overridden. Check `uvicorn app:app --help` for more details. Anyway! Now, on to sending test payloads!
> If you were to install the cruel closer app, any repositories that you give the GitHub app access to will cruelly close all new issues, be careful.
71
-
72
70
#### Deploy your GitHub App
73
71
74
72
Bear in mind that you will need to run the app _somewhere_. It is possible, and fairly easy, to host the app in something like Kubernetes, or simply containerised, in a machine somewhere. You will need to be careful to expose the FastAPI app port to the outside world so the app can receive the payloads from Github. The deployed FastAPI app will need to be reachable from the same URL you set as the `webhook url`. However, this is getting a little bit into Docker/Kubernetes territory so we will not go too deep.
@@ -77,14 +75,13 @@ Bear in mind that you will need to run the app _somewhere_. It is possible, and
77
75
78
76
### `GitHubApp` Instance Attributes
79
77
80
-
`payload`: In the context of a hook request, a Python dict representing the hook payload (raises a `RuntimeError`
81
-
outside a hook context).
78
+
`payload`: In the context of a webhook request, a Python dict representing the hook payload (raises a `GitHubAppError` outside a webhook context).
82
79
83
80
`installation_token`: The token used to authenticate as the app installation. This can be used to call api's not supported by `GhApi` like [Github's GraphQL API](https://docs.github.com/en/graphql/reference)
84
81
85
82
### `GithubApp` Instance Methods
86
83
87
-
`client`: a [GhApi](https://ghapi.fast.ai/) client authenticated as the app installation (raises a `RuntimeError` inside a hook context without a valid request)
84
+
`client`: a [GhApi](https://ghapi.fast.ai/) client authenticated as the app installation (raises a `GitHubAppError` outside a webhook context without a valid installation)
88
85
89
86
## Rate Limiting
90
87
@@ -158,7 +155,7 @@ FastAPI-GitHubApp includes built-in OAuth2 support for user authentication and a
158
155
159
156
### Setup
160
157
161
-
OAuth2 is enabled when you provide both `oauth_client_id` and `oauth_client_secret`. The `oauth_session_secret` is **required** for session management:
158
+
OAuth2 is enabled when you provide both `oauth_client_id` and `oauth_client_secret` (via constructor parameters or environment variables). The `oauth_session_secret` is **required** for session management:
162
159
163
160
```python
164
161
from githubapp import GitHubApp
@@ -168,7 +165,7 @@ github_app = GitHubApp(
168
165
github_app_id=12345,
169
166
github_app_key=private_key,
170
167
github_app_secret=webhook_secret,
171
-
# OAuth2 configuration - all required for OAuth2 to work
168
+
# OAuth2 configuration - required for OAuth2 to work
You can find an example on how to init all these config variables in the [cruel_closer sample app](./samples/cruel_closer)
333
+
You can find an example on how to init all these config variables in the [basic webhook sample app](./samples/01-basic-webhook)
335
334
336
335
#### OAuth2 Example
337
336
338
-
The [oauth2_example](./samples/oauth2_example) demonstrates GitHub OAuth2 authentication with web interface, protected routes, and session management. It shows two approaches:
337
+
The [OAuth2 integration sample](./samples/03-oauth2-integration) demonstrates GitHub OAuth2 authentication with web interface, protected routes, and session management. It shows two approaches:
339
338
340
339
-**Environment-only configuration** (recommended): Load all settings from environment variables
341
340
-**Constructor parameters**: Pass OAuth2 settings explicitly to GitHubApp
342
341
343
-
#### Cruel Closer
344
-
345
-
The cruel-closer sample app will use information of the received payload (which is received every time an issue is opened), will find said issue and **close it** without regard.
0 commit comments