Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94698 > unrolled thread
| Started by | devnzyme1@use.startmail.com |
|---|---|
| First post | 2015-07-28 08:34 -0700 |
| Last post | 2015-07-29 08:01 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
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
| From | devnzyme1@use.startmail.com |
|---|---|
| Date | 2015-07-28 08:34 -0700 |
| Subject | Using 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]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-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]
| From | dieter <dieter@handshake.de> |
|---|---|
| Date | 2015-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