Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'debug': 0.07; 'http': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:a 10': 0.09; 'url:github': 0.09; 'appreciated!': 0.16; 'headers.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'request)': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'machine': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'sends': 0.24; 'header': 0.24; 'question': 0.24; 'login': 0.25; 'pass': 0.26; 'header:X -Complaints-To:1': 0.27; 'host': 0.29; 'chris': 0.29; 'am,': 0.29; 'code': 0.31; 'correctly.': 0.31; 'skip:q 20': 0.31; 'writes:': 0.31; 'file': 0.32; 'subject:with': 0.35; 'basic': 0.35; 'connection': 0.35; 'created': 0.35; '14,': 0.36; 'url:org': 0.36; 'skip:4 10': 0.37; 'being': 0.38; 'message-id:@gmail.com': 0.38; 'work?': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'establish': 0.61; 'name': 0.63; 'response.': 0.68; 'obvious': 0.74; 'saw': 0.77; 'application?': 0.84; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Akira Li <4kir4.1i@gmail.com> Subject: Re: httplib with NETRC authentication Date: Wed, 14 May 2014 19:44:00 +0400 References: Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: 89.169.229.68 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:W5H0Pf6wOB2xoclRd+fNaU9s0bQ= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1400082607 news.xs4all.nl 2936 [2001:888:2000:d::a6]:49002 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71566 Chris Angelico writes: > On Wed, May 14, 2014 at 9:33 AM, pratibha natani wrote: >> I am trying to establish http connection to a gerrit host using >> netrc authentication. I have a netrc file created with following >> entries: >> machine host1.com login name password pass >> >> I did a debug and saw that my netrc file is being read >> correctly. Also in the connection object(after sending request) a >> header got created with appropriate credentials: >> 'headers': {'Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ='} >> >> Still I get 401,Unauthorized in response. Any help would be greatly appreciated! > > The obvious question is: What *does* work? Does it work when you use > wget, or some other application? Then go and look at what that sends > for its authentication headers. Tip: It won't be "Authorization". "Authorization" is the appropriate header for basic http authentication: http://tools.ietf.org/html/rfc2617#section-2 Here's a code example for urllib2: https://gist.github.com/kennethreitz/973705#comment-56387 -- akira