Python Forum
http.client.HTTPSConnection and user authentication?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
http.client.HTTPSConnection and user authentication?
#2
I sorted it out myself. If someone is looking for the answer, here is the code:

import http.client
import ssl
import ubase64

user="USERNAME"
passwd="PASSWORD"

headers = {"Authorization":"Basic {}".format(base64.b64encode(bytes(f"{user}:{passwd}","utf-8")).decode("ascii"))}
 
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations('mywonca.crt')
conn = http.client.HTTPSConnection('somedomain.com', 443, context=context)
conn.request("GET","/rest/api/something",headers=headers)
r1 = conn.getresponse()
Reply


Messages In This Thread
RE: http.client.HTTPSConnection and user authentication? - by geekgeek - Apr-06-2020, 01:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Prompt of Access ( Authentication Http ) ? JohnnyCoffee 4 1,726 Dec-08-2022, 12:42 PM
Last Post: DeaD_EyE
  IMAP authentication matt_the_hall 0 2,007 Feb-23-2021, 08:38 PM
Last Post: matt_the_hall

Forum Jump:

User Panel Messages

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