cli
cli copied to clipboard
`.netrc` not read by snap
Minimal reproduction code and steps
- Install snap:
snap install httpie
- Setup a
.netrc
file - Try it
.netrc
machine api.opensuse.org
login myusername
password mypassword
Current result
$ http --version
3.2.1
$ http "https://api.opensuse.org/source/home:apritschet"
HTTP/1.1 401 Unauthorized
...
Also, in combination with the environment variable NETRC
I keep getting a 401 response.
Expected result
httpie should honor the .netrc
file even when used as a snap. httpie installed from the Ubuntu repos does.
Debug output
Please re-run the command with --debug
, then copy the entire command & output and paste both below:
$ http --debug https://api.opensuse.org/source/home:apritschet
HTTPie 3.2.1
Requests 2.27.1
Pygments 2.12.0
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0]
/snap/httpie/369/bin/python3
Linux 5.15.0-56-generic
<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7ff369fac670>,
'args': Namespace(),
'as_silent': <function Environment.as_silent at 0x7ff369fac550>,
'colors': 256,
'config': {'default_options': []},
'config_dir': PosixPath('/home/andi/snap/httpie/369/.config/httpie'),
'devnull': <property object at 0x7ff369fbdbd0>,
'is_windows': False,
'log_error': <function Environment.log_error at 0x7ff369fac5e0>,
'program_name': 'http',
'quiet': 0,
'rich_console': <functools.cached_property object at 0x7ff36a023700>,
'rich_error_console': <functools.cached_property object at 0x7ff369fc4850>,
'show_displays': True,
'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
'stderr_isatty': True,
'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
'stdin_encoding': 'utf-8',
'stdin_isatty': True,
'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
'stdout_encoding': 'utf-8',
'stdout_isatty': True}>
<PluginManager {'adapters': [<class 'httpie_unixsocket.UnixSocketTransportPlugin'>,
<class 'httpie_snapdsocket.SnapdSocketTransportPlugin'>],
'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
<class 'httpie.plugins.builtin.DigestAuthPlugin'>,
<class 'httpie.plugins.builtin.BearerAuthPlugin'>],
'converters': [],
'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
<class 'httpie.output.formatters.json.JSONFormatter'>,
<class 'httpie.output.formatters.xml.XMLFormatter'>,
<class 'httpie.output.formatters.colors.ColorFormatter'>]}>
>>> requests.request(**{'auth': None,
'data': RequestJSONDataDict(),
'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.2.1')>,
'method': 'get',
'params': <generator object MultiValueOrderedDict.items at 0x7ff369c3db30>,
'url': 'https://api.opensuse.org/source/home:apritschet'})
HTTP/1.1 401 Unauthorized
Accept-Ranges: bytes
Connection: Upgrade, Keep-Alive
Content-Language: en
Content-Type: text/html; charset=utf-8
Date: Wed, 04 Jan 2023 12:11:44 GMT
Keep-Alive: timeout=15, max=100
Server: Apache
Strict-Transport-Security: max-age=31536000
Transfer-Encoding: chunked
Upgrade: h2
Vary: accept-language,accept-charset
WWW-Authenticate: Basic realm="Use your SUSE developer account"
...
Pardon me for not including all the HTML output.
I was also confused by the documentation:
Authentication information from your
~/.netrc
file is by default honored as well.
It does not seem to work within httpie
version 3.2.1
at the moment.
https://github.com/httpie/httpie/blob/b16392fbb9aee707c0449f10dab6bfd9ad4b8799/docs/README.md?plain=1#L1357-L1376
Related issue:
- https://github.com/httpie/httpie-ntlm/issues/6
i am not sure what snap
is but i am having the same issue
on mac via brew install httpie