-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
Garot Conklin edited this page Jan 28, 2025
·
1 revision
This guide covers common issues you might encounter when using githubauthlib and their solutions.
-
get_github_token()
returnsNone
- No error is raised, but no token is returned
- Git credentials not configured
- Token not stored in system keychain
- Token stored with incorrect protocol/host
- Verify Git credentials are configured:
# Check Git configuration
git config --global credential.helper
# macOS
git config --global credential.helper osxkeychain
# Windows
git config --global credential.helper manager
# Linux
git config --global credential.helper libsecret
- Store credentials manually:
# This will prompt for your credentials
git credential-osxkeychain store
protocol=https
host=github.com
username=your-username
password=ghp_your_token
-
CredentialHelperError
is raised - "Permission denied" or similar error message
- Insufficient permissions for keychain access
- System keychain locked
- Application not trusted by system
- Open Keychain Access
- Find the GitHub entry
- Update permissions for the credential
- Open Credential Manager
- Check Generic Credentials
- Verify GitHub credentials exist
- Check libsecret installation:
which secret-tool
- Test libsecret access:
secret-tool lookup host github.com
-
UnsupportedPlatformError
is raised - "Unsupported operating system" message
-
Verify your operating system is supported:
- macOS
- Windows
- Linux
-
Check platform-specific dependencies:
# Linux
sudo apt-get install libsecret-tools # Ubuntu/Debian
sudo dnf install libsecret # Fedora
sudo pacman -S libsecret # Arch Linux
- Token validation fails
-
validate_token()
returnsFalse
-
Verify token format:
- Classic tokens: 40 hexadecimal characters
- Fine-grained tokens:
ghp_
prefix followed by 36 characters - Server tokens:
ghs_
prefix followed by 36 characters
-
Generate a new token:
- Go to GitHub Settings > Developer settings > Personal access tokens
- Generate new token
- Store token securely
ModuleNotFoundError
ImportError
- Verify installation:
pip list | grep githubauthlib
- Reinstall package:
pip uninstall githubauthlib
pip install githubauthlib
- Check Python version:
python --version # Should be 3.6 or higher
- No log output
- Insufficient log information
- Configure logging:
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
- Enable debug logging for the library:
logging.getLogger('githubauthlib').setLevel(logging.DEBUG)
# Python version
python --version
# Installed packages
pip freeze
# Operating system
python -c "import platform; print(platform.system())"
# Check Git version
git --version
# List Git configuration
git config --list
# Test Git credential helper
git credential fill <<EOF
protocol=https
host=github.com
EOF
security find-generic-password -s github.com
cmdkey /list | findstr github.com
secret-tool search host github.com
If you're still experiencing issues:
- Enable debug logging and collect logs
- Check the GitHub Issues
- Create a new issue with:
- Operating system and version
- Python version
- Installation method
- Error messages
- Steps to reproduce
- Debug logs (with sensitive information removed)
try:
token = get_github_token()
except CredentialHelperError as e:
if "not found" in str(e):
print("Credential helper not configured")
elif "permission denied" in str(e):
print("Permission issues with credential helper")
else:
print(f"Unknown credential helper error: {e}")
try:
token = get_github_token()
except UnsupportedPlatformError as e:
print(f"System not supported: {platform.system()}")
- Token retrieval takes more than 1 second
- System appears to hang
- Cache the token:
from functools import lru_cache
@lru_cache(maxsize=1)
def get_cached_token():
return get_github_token()
- Check system keychain performance:
- Remove unused credentials
- Update system keychain software
- Check system resources
- Never log tokens
- Use environment variables when needed
- Rotate tokens regularly
- Use fine-grained tokens
- Set appropriate token permissions
For security-related issues:
- DO NOT create a public issue
- Email [email protected]
- Include detailed information
- Follow responsible disclosure