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
#1
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\connectionpool.py:979: InsecureRequestWarning: Unverified HTTPS request is being made to host 'services.fiberlink.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest...l-warnings
warnings.warn(
<!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 = "https://services.fiberlink.com/auth-apis/auth/1.0/authenticate/1008860"
token_dict = """<authRequest>
                <maaS360AdminAuth>
                    <billingID>1008860</billingID>
                    <platformID>3</platformID>
                    <appID>com.1008860.api</appID>
                    <appVersion>1.0</appVersion>
                    <appAccessKey>XXXXXXXX</appAccessKey>
                    <userName>XXXXXXXX</userName>
                    <password>XXXXXXXX</password>
                </maaS360AdminAuth>
            </authRequest>
"""
headers1 = {"Content-Type": "application/xml"}
response = requests.post(apiURL_auth, 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>","")
print(token_Key)


# API URL for module data
apiURL_main ="https://services.fiberlink.com/device-apis/devices/1.0/search/1008860/?deviceStatus=Active&partialDeviceName=UKC0"
header2 = {"Authorization": "MaaS token=%s" % token_Key}
response2 = requests.get(apiURL_main, headers=header2, verify=False)
print(response2.text)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  saml2 idp sso authentication tiagome 1 2,148 Apr-08-2022, 02:38 PM
Last Post: snippsat
  Unable to access javaScript generated data with selenium and headless FireFox. pjn4 0 2,544 Aug-04-2019, 11:10 AM
Last Post: pjn4
  Unable to gather data using beautifulscoup() [Output shows blank file] rishab123s 1 3,127 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 3,498 Oct-04-2017, 11:18 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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