Skip to content

Commit 8177b79

Browse files
DEVOPS-46
1 parent bcc89cc commit 8177b79

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

generate_jwt.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ def create_jwt(private_key, app_id):
3636
print(f"JWT set as environment variable: JWT={encoded_jwt}")
3737
return encoded_jwt
3838

39+
def make_github_api_request():
40+
url = " https://api.github.com/apps"
41+
headers = {
42+
"Accept": "application/vnd.github+json",
43+
"Authorization": f"Bearer {os.getenv('GITHUB_JWT')}",
44+
"X-GitHub-Api-Version": "2022-11-28"
45+
}
46+
47+
response = requests.get(url, headers=headers)
48+
response_json = response.json()
49+
50+
if response.status_code == 200:
51+
print("API request successful:")
52+
print(response_json)
53+
else:
54+
print(f"API request failed with status code {response.status_code}:")
55+
print(response_json)
3956
def main():
4057
"""
4158
to test the code
@@ -51,6 +68,7 @@ def main():
5168

5269
# function call
5370
create_jwt(private_key, app_id)
71+
make_github_api_request()
5472

5573
if __name__ == "__main__":
5674
main()

use_jwt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def make_github_api_request():
6-
url = " https://api.github.com/repositories"
6+
url = " https://api.github.com/apps"
77
headers = {
88
"Accept": "application/vnd.github+json",
99
"Authorization": f"Bearer {os.getenv('GITHUB_JWT')}",

0 commit comments

Comments
 (0)