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


Groups > comp.lang.python > #94721

Re: Using requests with an Authorization header?

From dieter <dieter@handshake.de>
Subject Re: Using requests with an Authorization header?
Date 2015-07-29 08:01 +0200
References <f6254791-7816-4a9c-8260-b536af42e36d@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1059.1438149722.3674.python-list@python.org> (permalink)

Show all headers | 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