2

It seems morningstar login solution in How can I log in to morningstar.com without using a headless browser such as selenium? is not working anymore for me. I get error message {'message': 'Forbidden'} and I believe this is because of the login_url used in the solution "https://www.morningstar.com/api/v2/user/login"

Is there any workaround?

import requests

s = requests.session()
auth_url = 'https://sso.morningstar.com/sso/json/msusers/authenticate'
login_url = 'https://www.morningstar.com/api/v2/user/login'
username = 'username'
password = 'password'

headers = {
    'Access-Control-Request-Method': 'POST',
    'Access-Control-Request-Headers': 'content-type,x-openam-password,x-openam-username',
    'Origin': 'https://www.morningstar.com'
}
s.options(auth_url, headers=headers)

headers = {
    'Referer': 'https://www.morningstar.com/members/login.html',
    'Content-Type': 'application/json',
    'X-OpenAM-Username': username,
    'X-OpenAM-Password': password,
    'Origin': 'https://www.morningstar.com',
}
s.post(auth_url, headers=headers)

data = {"productCode":"DOT_COM","rememberMe":False}
r = s.post(login_url, json=data)

print(s.cookies)
print(r.json())
  • I have pointed @t.m.adam to your question. Hopefully he can help us out. I am unable to solve it. I think the `referer` has changed to `https://www.morningstar.com/sign-in`. Did you reach the same conclusion? I get this error message when accessing the `auth_url` in my browser: `{"code":405,"reason":"Method Not Allowed","message":"Method Not Allowed"}` – tommy.carstensen Aug 22 '19 at 20:04

0 Answers0