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


Groups > comp.lang.python > #94698 > unrolled thread

Using requests with an Authorization header?

Started bydevnzyme1@use.startmail.com
First post2015-07-28 08:34 -0700
Last post2015-07-29 08:01 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  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

#94698 — Using requests with an Authorization header?

Fromdevnzyme1@use.startmail.com
Date2015-07-28 08:34 -0700
SubjectUsing requests with an Authorization header?
Message-ID<f6254791-7816-4a9c-8260-b536af42e36d@googlegroups.com>
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



http://docs.python-requests.org/en/latest/user/authentication/#basic-authentication

[toc] | [next] | [standalone]


#94699

FromChris Angelico <rosuav@gmail.com>
Date2015-07-29 01:49 +1000
Message-ID<mailman.1050.1438098553.3674.python-list@python.org>
In reply to#94698
On Wed, Jul 29, 2015 at 1:34 AM,  <devnzyme1@use.startmail.com> wrote:
> but that's not working

This is, I'm sorry to say, almost completely unhelpful - and also
extremely common. Can you please post the full details of (a) what you
did, (b) what happened or didn't happen, and (c) what you expect to
happen?

For example, are you sure the server supports what you're trying to do?

ChrisA

[toc] | [prev] | [next] | [standalone]


#94721

Fromdieter <dieter@handshake.de>
Date2015-07-29 08:01 +0200
Message-ID<mailman.1059.1438149722.3674.python-list@python.org>
In reply to#94698
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'".

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web