Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.netrc not read by snap #1465

Open
crazyscientist opened this issue Jan 4, 2023 · 2 comments
Open

.netrc not read by snap #1465

crazyscientist opened this issue Jan 4, 2023 · 2 comments
Labels
bug Something isn't working new Needs triage. Comments are welcome!

Comments

@crazyscientist
Copy link

Minimal reproduction code and steps

  1. Install snap: snap install httpie
  2. Setup a .netrc file
  3. 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.

@crazyscientist crazyscientist added bug Something isn't working new Needs triage. Comments are welcome! labels Jan 4, 2023
@remcotolsma
Copy link

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:

@fkowal
Copy link

fkowal commented Jun 9, 2023

i am not sure what snap is but i am having the same issue

on mac via brew install httpie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!
Projects
None yet
Development

No branches or pull requests

3 participants