Skip to content

Commit b0ea1a7

Browse files
committed
add: example
1 parent c43ac1b commit b0ea1a7

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

example/test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
import githubapps
3+
from github import Github
4+
5+
# using an access token
6+
7+
8+
def main():
9+
with open('env/private.key', 'rb') as f_private:
10+
private_key = f_private.read()
11+
with open('env/app_id.key', 'r') as f_app_id:
12+
app_id = f_app_id.read()
13+
with open('env/installation_id.key', 'r') as f_installation_id:
14+
installation_id = f_installation_id.read()
15+
client_secret = private_key
16+
auth = githubapps.AiohttpAuth(app_id, installation_id, client_secret)
17+
access_token = auth.get_access_token()
18+
19+
g = Github(access_token)
20+
print(access_token)
21+
if __name__ == "__main__":
22+
main()

example/testasync.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import githubapps
3+
from github import Github
4+
import asyncio
5+
6+
# using an access token
7+
8+
9+
async def main():
10+
with open('env/private.key', 'rb') as f_private:
11+
private_key = f_private.read()
12+
with open('env/app_id.key', 'r') as f_app_id:
13+
app_id = f_app_id.read()
14+
with open('env/installation_id.key', 'r') as f_installation_id:
15+
installation_id = f_installation_id.read()
16+
client_secret = private_key
17+
auth = githubapps.AiohttpAuth(app_id, installation_id, client_secret)
18+
access_token = await auth.get_access_token()
19+
20+
g = Github(access_token)
21+
print(access_token)
22+
if __name__ == "__main__":
23+
asyncio.run(main())

0 commit comments

Comments
 (0)