0

My company changed the URL for the company wiki. Now, when I use the new URL authentication is broken in python requests, where it was working before the change.

Under the new URL, I can only authenticate to the front page:

auth = ('myser', 'mypass')
url = 'https://msvcs.us.cworld.company.com/eailrr/User/Logon'
page = requests.get(url, auth=auth)
page
<Response [200]>

However, when I try to GET for the page I actually need I get a 401 error:

url = 'https://msvcs.us.cworld.company.com/wiki/rest/api/content'
page = requests.get(url, auth=auth)
page.raise_for_status
<bound method Response.raise_for_status of <Response [401]>>

Please note: I am unable to post actual company URLs in a public place. They are not accessible off the network anyway.

I am using the same exact auth for both requests. Why do I get a 200 for the first request, but a 401 for the second request?

bluethundr
  • 1,005
  • 17
  • 68
  • 141
  • 1
    You're missing some sort of authorization token. You only need to authorize once, and you're given a token to use. – Trevor Jul 23 '19 at 16:56
  • 1
    Changing the url itself probably won't have broken authentication, it is more likely they added token based auth or something similar. This would be a good question to ask whoever is running this service. – CMMCD Jul 23 '19 at 16:57
  • 1
    if the service provider still uses the username password based auth then you probably need to you session = requests.Session() session.auth = (user, password) auth = session.post("https://msvcs.us.cworld.company.com/wiki/rest/api/content") – backtrack Jul 23 '19 at 16:59
  • Possible duplicate of [Basic authentication not working with Requests library](https://stackoverflow.com/questions/26745462/basic-authentication-not-working-with-requests-library) – backtrack Jul 23 '19 at 17:00
  • They implented kerberos authentication without telling anybody. When we had a meeting with that team they let us know. I added the requests kerberos library to my scripts and now I'm authenticating again. Thanks for the help, guys! – bluethundr Jul 24 '19 at 15:00

0 Answers0