@@ -65,7 +65,7 @@ from githubkit import GitHub, BasicAuthStrategy
6565github = GitHub(BasicAuthStrategy(" <client_id_here>" , " <client_secret_here>" ))
6666```
6767
68- ### Call Rest API
68+ ### Calling Rest API
6969
7070> APIs are fully typed. Typing in the following examples is just for reference only.
7171
@@ -133,7 +133,7 @@ async for issue in github.paginate(
133133 print (issue.number)
134134```
135135
136- ### Call GraphQL API
136+ ### Calling GraphQL API
137137
138138Simple sync call:
139139
@@ -146,3 +146,48 @@ Simple async call:
146146``` python
147147data: Dict[str , Any] = github.async_graphql(query, variables = {" foo" : " bar" })
148148```
149+
150+ ### Webhook Verification
151+
152+ Simple webhook payload verification:
153+
154+ ``` python
155+ from githubkit.webhooks import verify
156+
157+ valid: bool = verify(secret, request.body, request.headers[" X-Hub-Signature-256" ])
158+ ```
159+
160+ Sign the webhook payload manually:
161+
162+ ``` python
163+ from githubkit.webhooks import sign
164+
165+ signature: str = sign(secret, payload, method = " sha256" )
166+ ```
167+
168+ ### Webhook Parsing
169+
170+ Parse the payload with event name:
171+
172+ ``` python
173+ from githubkit.webhooks import parse, WebhookEvent
174+
175+ event: WebhookEvent = parse(request.headers[" X-GitHub-Event" ], request.body)
176+ ```
177+
178+ Parse the payload without event name (may cost longer time):
179+
180+ ``` python
181+ from githubkit.webhooks import parse_without_name, WebhookEvent
182+
183+ event: WebhookEvent = parse_without_name(request.body)
184+ ```
185+
186+ Parse dict like payload:
187+
188+ ``` python
189+ from githubkit.webhooks import parse_obj, parse_obj_without_name, WebhookEvent
190+
191+ event: WebhookEvent = parse_obj(request.headers[" X-GitHub-Event" ], request.json())
192+ event: WebhookEvent = parse_obj_without_name(request.json())
193+ ```
0 commit comments