-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_git.py
More file actions
36 lines (30 loc) · 1.06 KB
/
verify_git.py
File metadata and controls
36 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import requests
from dotenv import load_dotenv
load_dotenv()
token = os.getenv("GITHUB_TOKEN")
repo = "Kaus-code/AutoIssueScrapper"
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.v3+json"
}
print(f"Verifying token for repo: {repo}")
# Check user info
r_user = requests.get("https://api.github.com/user", headers=headers)
if r_user.status_code == 200:
user_data = r_user.json()
print(f"Authenticated as: {user_data.get('login')}")
else:
print(f"Failed to authenticate: {r_user.status_code} - {r_user.text}")
# Check repo access
r_repo = requests.get(f"https://api.github.com/repos/{repo}", headers=headers)
if r_repo.status_code == 200:
repo_data = r_repo.json()
permissions = repo_data.get("permissions", {})
print(f"Repo Permissions: {permissions}")
if permissions.get("push"):
print("✅ Token has PUSH access.")
else:
print("❌ Token does NOT have push access.")
else:
print(f"Failed to access repo: {r_repo.status_code} - {r_repo.text}")