-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: document AppInstallationAuth.get_token()
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,34 @@ async with AppClient(app_id, privkey) as session: | |
resp = await session.get("/octocat") | ||
``` | ||
|
||
### Obtain an app token for use with git | ||
|
||
Under the hood, the `AppClient` uses the `AppAuth` and `AppInstallationAuth` | ||
objects to obtain a GitHub token. It can also be used to pull or push from a | ||
repository. | ||
|
||
The token can be obtained as follows for a given installation of the app. | ||
|
||
```python | ||
app_auth = AppAuth(app_id, privkey) | ||
inst_auth = AppInstallationAuth(app_auth, owner, repositories=["simple-github"]) | ||
return await inst_auth.get_token() | ||
``` | ||
|
||
The `get_token` method doesn't natively support synchronous calls, but it can | ||
easily be called from synchronous code with | ||
|
||
```python | ||
return asyncio.run(inst_auth.get_token()) | ||
``` | ||
|
||
The returned token (`ghs_XXX`) can be used directly to authenticate git+http | ||
operations as the `git` user. | ||
|
||
``` | ||
git remote set-url origin https://git:[email protected]/mozilla-releng/simple-github | ||
``` | ||
|
||
### No Authentication | ||
|
||
Finally you can create a client without any authentication. This is mainly | ||
|