Python Forum
Unable to get the data from web API using authentication key
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to get the data from web API using authentication key
Hi team,

I have generated token key and when try to pass request to get the data from API using token key, facing below error message.

"D:\Users\lth\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\ InsecureRequestWarning: Unverified HTTPS request is being made to host ''. Adding certificate verification is strongly advised. See:
<!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">"

Could you please help me on this.

import requests

# API URL to generate authentication token key
apiURL_auth = ""
token_dict = """<authRequest>
headers1 = {"Content-Type": "application/xml"}
response =, data=token_dict, headers=headers1)
auth_token = response.text
index_1 = auth_token.index("<authToken>")
index_2 = auth_token.index("</authToken>")
index_3 = auth_token.index("<errorCode>")
index_4 = auth_token.index("</errorCode>")
error_code = auth_token[index_3:index_4].replace("<errorCode>","")
token_Key = auth_token[index_1:index_2].replace("<authToken>","")

# API URL for module data
apiURL_main =""
header2 = {"Authorization": "MaaS token=%s" % token_Key}
response2 = requests.get(apiURL_main, headers=header2, verify=False)

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to add proxy authentication selenium farhan275 10 7,134 Sep-10-2020, 10:18 PM
Last Post: farhan275
  Webscrapping of Images that requires Authentication junos4350 1 882 Jun-08-2020, 08:32 AM
Last Post: alekson
  Unable to access javaScript generated data with selenium and headless FireFox. pjn4 0 1,229 Aug-04-2019, 11:10 AM
Last Post: pjn4
  Twitter authentication failure with Tweepy HSB 1 1,449 Feb-03-2019, 01:30 PM
Last Post: HSB
  Unable to gather data using beautifulscoup() [Output shows blank file] rishab123s 1 1,924 Apr-13-2018, 04:35 PM
Last Post: snippsat
  Unable to print data while looping through list in csv for webscraping - Python Prince_Bhatia 1 2,176 Oct-04-2017, 11:18 AM
Last Post: wavic
  authentication and os.environ questions jdischler 0 2,358 May-04-2017, 04:25 PM
Last Post: jdischler

Forum Jump:

User Panel Messages

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