-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_github_api.py
More file actions
34 lines (30 loc) · 1012 Bytes
/
test_github_api.py
File metadata and controls
34 lines (30 loc) · 1012 Bytes
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
import os
async def test_github_access():
token = os.getenv("GITHUB_TOKEN")
if not token:
print("Error: GITHUB_TOKEN environment variable not set")
return
headers = {
"Authorization": f"Bearer {token}",
"Accept": "application/vnd.github+json"
}
async with httpx.AsyncClient() as client:
print("Testing rate limit...")
# Test rate limit
response = await client.get(
"https://api.github.com/rate_limit",
headers=headers
)
print(f"Status: {response.status_code}")
print(response.json())
print("\nTesting search...")
# Test search
response = await client.get(
"https://api.github.com/search/users",
params={"q": "anthropic.com", "type": "org"},
headers=headers
)
print(f"Status: {response.status_code}")
print(response.json())
if __name__ == "__main__":
asyncio.run(test_github_access())