Python Forum
httplib2 - how to see credentials added by add_credentials?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
httplib2 - how to see credentials added by add_credentials?
#1
environment: OS xUbuntu 18.04.4; Python 3.6.9; httplib2==0.9.2

I'm using httplib2 in such Python code (for some REST POST-request testing):

import httplib2, json
httplib2.debuglevel = 4
h = httplib2.Http('.cache')
data = {"quantity": 1,"product": 15, "product_code": "1004"}
data = json.dumps(data)
restEndpointURL='http://localhost:8000/shop/api/cart/?format=json'
h.add_credentials('a_login', 'a_password', 'localhost')
headersDict={'Content-Type':'application/json','accept':'application/json'}
response, content = h.request(restEndpointURL,'POST',data,headers=headersDict)
According to this code (httplib2.debuglevel and add_credentials) I suppose to see in the httplib2 debug output something like:
Authorization: Basic blablabla
but there is nothing like this.

So I need some ideas - how to check out what exactly was sent by httplib2 to the server?
Reply
#2
UPDATED.
Well, looks like code
h.add_credentials('a_login', 'a_password', 'localhost')
doesn't work at all.
I checked it adding requests-logging functionality to my backend (that's django-shop server) and than executing the same POST-request via curl utility with corresponding --user parameter. So using curl-command I got what I waited to see - 'Authorization': 'Basic blablabla' in the log-while (headers dictionary), but using httplib2 with add_credentials I got nothing like this.
Reply
#3
UPDATED-2.
I updated my httplib2 from it's official github repository to the 0.18.1 (gzip) version (the last one) - and got the same result.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python beginner that needs an expression added to existing script markham 1 707 Sep-04-2023, 05:24 AM
Last Post: Pedroski55
  Cannot find py credentials file standenman 5 1,652 Feb-25-2023, 08:30 PM
Last Post: Jeff900
  [SOLVED] [BS] Why new tag only added at the end when defined outside the loop? Winfried 1 974 Sep-05-2022, 09:36 AM
Last Post: snippsat
  python application and credentials safety concern aster 4 3,523 Mar-06-2021, 06:51 PM
Last Post: snippsat
  Using python to execute app or cmd that requires admin credentials thewolf 0 2,117 Mar-05-2021, 08:15 PM
Last Post: thewolf
  How to show newly added column to csv johnson54937 3 2,211 Jan-07-2020, 04:01 AM
Last Post: Larz60+
  Recommended way to store users,db credentials in a Python project? PrateekG 2 12,321 May-31-2018, 12:22 PM
Last Post: DeaD_EyE
  Additional slashes being added to string burvil 8 13,858 Aug-04-2017, 04:15 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020