Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94721

Re: Using requests with an Authorization header?

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'wrapped': 0.07; 'library?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tuple.': 0.09; 'url:github': 0.09; 'headers': 0.15; 'literals': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:requests': 0.16; 'pass': 0.22; 'tried': 0.24; 'import': 0.24; 'header': 0.24; 'requests': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'anyone': 0.32; 'username': 0.33; 'i.e.': 0.35; 'but': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'anything': 0.38; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'received:de': 0.40; 'ever': 0.60; 'real': 0.62; 'subject:skip:A 10': 0.63; 'url:user': 0.63; 'received:217': 0.66; 'online': 0.71; 'subject:Using': 0.84; 'url:api': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: Using requests with an Authorization header?
Date Wed, 29 Jul 2015 08:01:54 +0200
References <f6254791-7816-4a9c-8260-b536af42e36d@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e0acb6.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:sSnEAga7uyQ4bAcK2BZ6VF5mbqQ=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1059.1438149722.3674.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438149722 news.xs4all.nl 2895 [2001:888:2000:d::a6]:35060
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3553
X-Received-Body-CRC 4010961733
Xref csiph.com comp.lang.python:94721

Show key headers only | View raw


devnzyme1@use.startmail.com writes:

> Has anyone ever used an authorization header with the requests library?  I tried using:
>
>
>>>> from requests.auth import HTTPBasicAuth
>>>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass')
>
> from their docs online but that's not working and I don't see anything about authorization headers

We are using it like this (successfully):

requests.post(url, data=data, params=params,
              auth=(user, passwd), timeout=timeout,
              verify=verify, headers=jsonHeaders,
              )

i.e. "user" and "password" are not wrapped into an "HTTPBasicAuth"
but directly passed as tuple. However, I expect that
it would also work with an "HTTPBasicAuth" wrapping.


Note that you must pass the real username and password, not
the literals "'user'" and "'pass'".

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Using requests with an Authorization header? devnzyme1@use.startmail.com - 2015-07-28 08:34 -0700
  Re: Using requests with an Authorization header? Chris Angelico <rosuav@gmail.com> - 2015-07-29 01:49 +1000
  Re: Using requests with an Authorization header? dieter <dieter@handshake.de> - 2015-07-29 08:01 +0200

csiph-web