Coverage for src/extratools_cloud/github/user.py: 0%

6 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-21 23:17 -0700

1from datetime import timedelta 

2 

3import httpx 

4from cachetools import TTLCache, cached 

5 

6 

7@cached(cache=TTLCache( 

8 maxsize=1_000, 

9 ttl=timedelta(hours=1).seconds, 

10)) 

11def get_username(bearer_token: str) -> str: 

12 # https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api 

13 return httpx.get( 

14 "https://api.github.com/user", 

15 headers={ 

16 "Authorization": f"Bearer {bearer_token}", 

17 }, 

18 ).json()["login"]