You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But turned out to be an issue with Python's netrc parser:
it appears that auth via netrc is broken if ~/.netrc includes entries that are not exactly login/password tuples. For example, I have the following entries for circle ci and heroku:
Traceback (most recent call last):
File "test.py", line 4, in <module>
netrc.netrc(os.path.expanduser('~/.netrc')).authenticators('api.github.com')
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.py", line 35, in __init__
self._parse(file, fp, default_netrc)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.py", line 117, in _parse
file, lexer.lineno)
netrc.NetrcParseError: bad follower token 'method' (/Users/ian/.netrc, line 7)
```\`
Python 3:
Traceback (most recent call last):
File "test.py", line 4, in
netrc.netrc(os.path.expanduser('~/.netrc')).authenticators('api.github.com')
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/netrc.py", line 30, in init
self._parse(file, fp, default_netrc)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/netrc.py", line 111, in _parse
file, lexer.lineno)
netrc.NetrcParseError: bad follower token 'method' (/Users/ian/.netrc, line 7)
Thanks for the report. There is no spec for .netrc files and the closest I can find is [0]. The error is present in master also. Could this be considered as an enhancement?
My PR #127 has tried to solve some restrictions of the current netrc library. It's somewhat outdated since no reviewer for a long time. As you can see there are also other libraries suffering from the restrictions.
Revising it I think it still doesn't solve the case here, although it should be easy. There is no formal spec we can refer to. :-( But since there is real world problem and curl allows it, we should take it into mind.
hober commented on Jun 17, 2020
hobermannequin
Mannequin
More actions
Emacs' netrc library supports some other keywords, namely 'port'. (This helps distinguish SMTP and IMAP auth information for the same machine.)
Activity
ianwremmel commentedon Oct 5, 2018
This started as a bug report for httpie httpie/cli#717 (comment)
And became a bug report for requests psf/requests#4813
I've used the following script to test python 2.7 and 3.7:
Python 2:
Traceback (most recent call last):
File "test.py", line 4, in
netrc.netrc(os.path.expanduser('~/.netrc')).authenticators('api.github.com')
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/netrc.py", line 30, in init
self._parse(file, fp, default_netrc)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/netrc.py", line 111, in _parse
file, lexer.lineno)
netrc.NetrcParseError: bad follower token 'method' (/Users/ian/.netrc, line 7)
tirkarthi commentedon Oct 5, 2018
Thanks for the report. There is no spec for .netrc files and the closest I can find is [0]. The error is present in master also. Could this be considered as an enhancement?
[0] https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html
Thanks
ianwremmel commentedon Oct 6, 2018
Yea, somehow, I suspected it was because there's no formal spec :)
I guess technically it's an enhancement, but given that configuration dictated by third-parties can break the environment, it does feel like a bug.
For example, I can't use a python app to authenticate to github via netrc because of how heroku says I have to configure my netrc.
Also, there are probably two subtly different issues:
[-]netrc parding is overly strict[/-][+]netrc parsing is overly strict[/+]zhangyangyu commentedon Oct 10, 2018
My PR #127 has tried to solve some restrictions of the current netrc library. It's somewhat outdated since no reviewer for a long time. As you can see there are also other libraries suffering from the restrictions.
Revising it I think it still doesn't solve the case here, although it should be easy. There is no formal spec we can refer to. :-( But since there is real world problem and curl allows it, we should take it into mind.
hober commentedon Jun 17, 2020
Emacs' netrc library supports some other keywords, namely 'port'. (This helps distinguish SMTP and IMAP auth information for the same machine.)
Documentation is here: https://www.gnu.org/software/emacs/manual/html_node/auth/Help-for-users.html
eamanu commentedon May 28, 2021
Hellos,
This issue is fixed via this PR[0] that is a continues from xiang.zhang work [1]
[0] #26330
[1] #127