Can't pass csrf token on factorio.com/login

Anything that prevents you from playing the game properly. Do you have issues playing for the game, downloading it or successfully running it on your computer? Let us know here.
Zickfor
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Mar 17, 2018 3:41 pm
Contact:

Can't pass csrf token on factorio.com/login

Post by Zickfor »

I need help with non-browser factorio.com auth.

I read instructions a lot of times maybe i am bit idiot, but anyway:

Code: Select all

import requests
from bs4 import BeautifulSoup

s = requests.session()
data = s.get('https://www.factorio.com/login')

soup = BeautifulSoup(data.content, 'html.parser')
token = soup.find_all('input', id='csrf_token')[0]['value']

newdata = s.post('https://www.factorio.com/login?csrf_token='+str(token)+'&username_or_email=&password=')
Returned page is saying, that 'The CSRF token is missing.'
Orygeunik
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed May 29, 2019 6:56 pm
Contact:

Re: Can't pass csrf token on factorio.com/login

Post by Orygeunik »

If yet actual, that fix this problem can with add header Referer.

For example this http request returned error (Token, session and password replaced to star (*)):

Code: Select all

POST /login HTTP/1.1
Host: www.factorio.com
Connection: keep-alive
Content-Length: 179
Content-Type: application/x-www-form-urlencoded
Cookie: session=***

csrf_token=***&next=&username_or_email=orygeunik&password=***&action=Login
This http request returned redirect (it's a normal action) (Token, session and password replaced to star (*)):

Code: Select all

POST /login HTTP/1.1
Host: www.factorio.com
Connection: keep-alive
Content-Length: 179
Content-Type: application/x-www-form-urlencoded
Referer: https://www.factorio.com/login
Cookie: session=***

csrf_token=***&next=&username_or_email=orygeunik&password=***&action=Login
Post Reply

Return to “Technical Help”