retrosheet using deprecated GitHub authentication
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
The [PyGithub](https://github.com/PyGithub/PyGithub?tab=readme-ov-file) package uses a new(er) form of PAT authentication to access the GitHub REST API. The code in [retrosheet.py](https://github.com/jldbc/pybaseball/blob/master/pybaseball/retrosheet.py) needs to be updated to reflect the new approach.
# Steps to replicate
Call any function that uses the `g = Github(GH_TOKEN)` line. For example,
```python
pybaseball.rosters(2023)
# or the more explicit :
pybaseball.retrosheet.rosters(2023)
```
# Issue details
The retrosheet.py file reads a `GH_TOKEN` environment variable that holds the user's GitHub personal access token.
```python
GH_TOKEN=os.getenv('GH_TOKEN', '')
```
It then passes the token when instantiating a `Github` object:
```python
g = Github(GH_TOKEN)
```
That triggers the following within the `github` library:
```python
File c:\...\Lib\site-packages\github\MainClass.py:230, in Github.__init__(self, login_or_token, password, jwt, app_auth, base_url, timeout, user_agent, per_page, verify, retry, pool_size, seconds_between_requests, seconds_between_writes, auth)
225 elif login_or_token is not None:
226 warnings.warn(
227 "Argument login_or_token is deprecated, please use " "auth=github.Auth.Token(...) instead",
228 category=DeprecationWarning,
229 )
--> 230 auth = github.Auth.Token(login_or_token)
231 elif jwt is not None:
232 warnings.warn(
233 "Argument jwt is deprecated, please use "
234 "auth=github.Auth.AppAuth(...) or "
235 "auth=github.Auth.AppAuthToken(...) instead",
236 category=DeprecationWarning,
237 )
```
Perhaps this is related to #414, although the notes make it look like that one is all set.
# How to fix
I got it working on my end using code similar to the following:
```python
from github import Github, Auth
...
auth = Auth.Token(GH_TOKEN)
g = Github(auth = auth)
```
Contributor guide
Assessment
This issue has not been assessed yet.