File tree Expand file tree Collapse file tree 5 files changed +15
-4
lines changed Expand file tree Collapse file tree 5 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ A Python library for securely retrieving GitHub tokens from system keychains acr
3232- Secure token retrieval with validation
3333- Comprehensive exception hierarchy for precise error handling
3434- Structured logging support
35- - Token format validation (supports both personal and fine-grained tokens)
35+ - Token format validation (supports personal, organization, and fine-grained tokens)
3636- Robust credential parsing and sanitization
3737
3838## Prerequisites
@@ -166,7 +166,7 @@ except GitHubAuthError as e:
166166 - Handle ` PlatformNotSupportedError ` exception
167167
1681684 . ** Invalid Token Format**
169- - Verify token starts with ` ghp_ ` or ` github_pat_ `
169+ - Verify token starts with ` ghp_ ` (personal), ` gho_ ` (organization), or ` github_pat_ ` (fine-grained)
170170 - Handle ` InvalidTokenError ` exception
171171
172172## Contributing
Original file line number Diff line number Diff line change 1414 get_github_token ,
1515)
1616
17- __version__ = "2.0.0 "
17+ __version__ = "2.0.1 "
1818__author__ = "garotm"
1919__license__ = "MIT"
2020
Original file line number Diff line number Diff line change @@ -58,10 +58,13 @@ def _validate_token(token: str) -> bool:
5858 return False
5959
6060 # GitHub personal access tokens start with 'ghp_' and are 40 characters long
61+ # GitHub organization tokens start with 'gho_' and are 40 characters long
6162 # GitHub fine-grained tokens start with 'github_pat_' and are longer
6263 # Allow for some flexibility in token length for testing
6364 if token .startswith ("ghp_" ) and len (token ) >= 40 :
6465 return True
66+ elif token .startswith ("gho_" ) and len (token ) >= 40 :
67+ return True
6568 elif token .startswith ("github_pat_" ) and len (token ) > 40 :
6669 return True
6770
Original file line number Diff line number Diff line change 88
99setup (
1010 name = "githubauthlib" ,
11- version = "2.0.0 " ,
11+ version = "2.0.1 " ,
1212 description = 'A library for authenticating with GitHub across different operating systems' ,
1313 long_description = long_description ,
1414 long_description_content_type = 'text/markdown' ,
Original file line number Diff line number Diff line change @@ -221,6 +221,14 @@ def test_validate_token_fine_grained(self):
221221 )
222222 self .assertTrue (_validate_token (fine_grained_token ))
223223
224+ def test_validate_token_organization (self ):
225+ """Test token validation with organization token."""
226+ from githubauthlib .github_auth import _validate_token
227+
228+ # Test organization token
229+ org_token = "gho_1234567890abcdef1234567890abcdef123456"
230+ self .assertTrue (_validate_token (org_token ))
231+
224232 @patch ("platform.system" )
225233 @patch ("subprocess.check_output" )
226234 def test_linux_libsecret_empty_output (self , mock_subprocess , mock_platform ):
You can’t perform that action at this time.
0 commit comments