401 Unauth error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: 401 Unauth error (/thread-38467.html) |
401 Unauth error - GUaro5555 - Oct-17-2022 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 RE: 401 Unauth error - ndc85430 - Oct-17-2022 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 ).
RE: 401 Unauth error - Larz60+ - Oct-17-2022 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. RE: 401 Unauth error - GUaro5555 - Oct-18-2022 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 RE: 401 Unauth error - Larz60+ - Oct-18-2022 you can't get off the launchpad without a good URL. RE: 401 Unauth error - GUaro5555 - Oct-18-2022 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 RE: 401 Unauth error - Larz60+ - Oct-19-2022 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: [attachment=2048] do you see the same page? If so, you can click on any of the buttons using selenium. RE: 401 Unauth error - GUaro5555 - Oct-19-2022 yes working on your suggeston Thanks a bunch |