Hello,
I hope I'm posting my question in the right section.
I'm trying to login to Magento account from Python script using requests module, the relevant code I made looks as below:
s = requests.session() main_url = '<redacted.tld>/en/index.html'
html_data = s.get('https://'+main_url, headers=headers, timeout=(30, 30), verify=dst_verify_ssl) web_user = 'test@test.com' web_pass = '123test321' form_key = soup.find('input', {'name':'form_key'})['value'] l_url = 'https://<redacted.tld>/'
l_route = 'en/customer/account/loginPost/'
login_payload = { 'form_key':form_key, 'login[username]':web_user, 'login[password]':web_pass } login_req = s.post(l_url + l_route, headers=headers, data=login_payload)
But it's not getting me logged in so I was wondering if someone could tell me what does it take to login via Python to the Magento account?
Thanks upfront.
Hi,
please try to use Token-based authentication instead of sending requests to loginPost controller. This should be helpful for you:
https://devdocs.magento.com/guides/v2.3/get-started/authentication/gs-authentication-token.html
Regards,
Marcin
Token-based authentication isn't available for me, therefore, the only way would be to login via a POST request.
I'm not sure what info needs to be submitted in the POST request and I've found no documentation so far, could you please point me into the right direction?
I'm either missing some header when sending POST to Magento or...., I've included about everything Chrome DOM inspector captured.
I didn't found related documentation either, for instance, I tried to authenticate via POST to WordPress, took just a few minutes.
There must be something I'm missing with Magento but I ran out of ideas.
Could you solve this finally? I'm stuck at the same point..