Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
401 Unauth error
#1
Hi gurus .

I m still very new to python so go easy on me, I have been trying to create this project that login to a website, what I have so far is the following:
import requests

LoginURL = 'https://logicmonitor.com/santaba/rest/setting/admins/services/signin'

Payload = {
      'username': 'username',
      'password': 'mypassword'
}

r = requests.post(LoginURL, params=Payload)

print(r.text)
once I run it I get the 401 auth error

can someone help me find out what I am doing wrong

Thanks
Larz60+ write Oct-17-2022, 01:22 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
fixed for you this time. Please use BBCode tags on future posts.
Reply
#2
Does the API you're making the request to have documentation? What does it say about authorisation? Usually, you don't pass credentials in the query string (i.e. with params in the call to post).
Reply
#3
Always try your URL from a browser when you receive a 401 error.

This URL is page not found error when trying to access from browser, so you will get same from python
Suggest going to site and finding a new working URL.
Reply
#4
ndc

I could not find anything on the vendor API, what I am trying to do is use py to login to the website, I used inspect to find the info I needed as username and password and the https:// I think is used in the post request, I used data= with the post first but I was getting the 401 error so I did try the params to see if that helped but nada.

any thoughts

Thanks
Reply
#5
you can't get off the launchpad without a good URL.
Reply
#6
Larz60

I can login with no issue from the browser, I am just trying to learn the step on how to do it from py

Thank a bunch
Reply
#7
When I try, using the URL from post 1 i get a 404 error. But then, it's really not an error at all but threw me off for a bit:

   

do you see the same page?
If so, you can click on any of the buttons using selenium.
Reply
#8
yes working on your suggeston

Thanks a bunch
Reply


Forum Jump:

User Panel Messages

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