401 Unauthorized on GitHub's API
Hello!
I've tried using the project but I have an issue with the HTTP requests towards the GitHub's API returning 401 errors.
I precise that I've changed the Chat model to use Microsoft Azure's OpenAI endpoints and they're working fine (or, at least, they return 200 OK responses, don't know about the actual content).
Is there something I've missed during setup?
The error in question:
2025-05-19 16:13:31,230 - INFO - HTTP Request: GET https://api.github.com/search/repositories?q=erp%20language%3Ajava&sort=stars&order=desc&per_page=25&page=1 "HTTP/1.1 401 Unauthorized"
2025-05-19 16:13:31,231 - INFO - [GitHub MCP Adapter] Fetched URL: https://api.github.com/search/repositories with status 401
2025-05-19 16:13:31,231 - ERROR - Error 401: Bad credentials
the 401 with body 'bad credentials' from the github search api means the token sent in the authorization header is missing, invalid, or expired, independent of the chat model. things to verify: 1) the env var name is exactly GITHUB_API_KEY, not GITHUB_TOKEN. 2) the .env file lives one directory above the DeepGit folder, since agent.py loads it via Path(file).resolve().parent.parent / '.env'. if your .env is inside DeepGit/, it will not be picked up. 3) the token has at least the public_repo scope for fine-grained pats, or the repo scope for classic pats. 4) the token has not expired. you can sanity check it directly with: curl -H 'authorization: token <your_key>' https://api.github.com/user. if that returns 401, the key itself is the problem. if it returns 200, the env loading is the problem and the .env location is the most likely cause.
in v4 the token env var is still GITHUB_API_KEY and it is loaded from a .env in the project root. there is now a check_setup tool (and cli path) that reports exactly whether the token is configured and hints what to fix, so this is much easier to diagnose. closing - please reopen if it still repros on v4.