@@ -331,9 +331,10 @@ For Django projects running with ASGI or in async views, the async client provid
331
331
from django_github_app.github import AsyncGitHubAPI
332
332
from django_github_app.models import Installation
333
333
334
+
334
335
# Access public endpoints without authentication
335
336
async def get_public_repo ():
336
- async with AsyncGitHubAPI () as gh:
337
+ async with AsyncGitHubAPI(" example-github-app " ) as gh:
337
338
return await gh.getitem(" /repos/django/django" )
338
339
339
340
@@ -344,14 +345,16 @@ async def create_comment(repo_full_name: str):
344
345
repositories__full_name=repo_full_name
345
346
)
346
347
347
- async with AsyncGitHubAPI(installation_id=installation.installation_id) as gh:
348
+ async with AsyncGitHubAPI(
349
+ " example-github-app" , installation_id=installation.installation_id
350
+ ) as gh:
348
351
await gh.post(
349
352
f" /repos/{repo_full_name}/issues/1/comments" , data={" body" : " Hello!" }
350
353
)
351
354
352
355
# You can either provide the `installation_id` as above, or the `Installation` instance
353
356
# itself
354
- async with AsyncGitHubAPI(installation=installation) as gh:
357
+ async with AsyncGitHubAPI(" example-github-app " , installation=installation) as gh:
355
358
await gh.post(
356
359
f" /repos/{repo_full_name}/issues/1/comments" , data={" body" : " World!" }
357
360
)
@@ -365,9 +368,10 @@ For traditional Django applications running under WSGI, the sync client provides
365
368
from django_github_app.github import SyncGitHubAPI
366
369
from django_github_app.models import Installation
367
370
371
+
368
372
# Access public endpoints without authentication
369
373
def get_public_repo_sync():
370
- with SyncGitHubAPI() as gh:
374
+ with SyncGitHubAPI("example-github-app" ) as gh:
371
375
return gh.getitem("/repos/django/django")
372
376
373
377
@@ -376,12 +380,14 @@ def create_comment_sync(repo_full_name: str):
376
380
# Get the installation for the repository
377
381
installation = Installation.objects.get(repositories__full_name=repo_full_name)
378
382
379
- with SyncGitHubAPI(installation_id=installation.installation_id) as gh:
383
+ with SyncGitHubAPI(
384
+ "example-github-app", installation_id=installation.installation_id
385
+ ) as gh:
380
386
gh.post(f"/repos/{repo_full_name}/issues/1/comments", data={"body": "Hello!"})
381
387
382
388
# You can either provide the `installation_id` as above, or the `Installation` instance
383
389
# itself
384
- with SyncGitHubAPI(installation=installation) as gh:
390
+ with SyncGitHubAPI("example-github-app", installation=installation) as gh:
385
391
gh.post(f"/repos/{repo_full_name}/issues/1/comments", data={"body": "World!"})
386
392
```
387
393
0 commit comments