Factorio Download API now requires CAPTCHA

Anything that prevents you play the game properly. Do you have issues with paying for the game, downloading it or properly running it on your computer? Let us know here.
Post Reply
Berserker55
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Jan 31, 2015 7:36 am
Contact:

Factorio Download API now requires CAPTCHA

Post by Berserker55 »

Hello, I was trying to follow https://wiki.factorio.com/Download_API to have an auto-downloader in my tool to make https://archipelago.gg/tutorial/Factorio/setup/en significantly simpler. However, I get "<li> Please pass the CAPTCHA. </li>" in my response, which makes this pretty much impossible. This should probably be noted on that page at the very least. I'm guessing there's not much of a solution?

in-progress download script:

Code: Select all

import requests
from Utils import is_windows, is_linux


def get_latest_factorio(user: str, password: str, version: str = "latest", build: str = "alpha"):
    if is_windows:
        distro = "win64-manual"
    elif is_linux:
        distro = "linux64"  # TODO: test
    else:
        raise NotImplemented(f"No auto downloader implemented for current platform.")

    login_url = 'https://factorio.com/login'
    with requests.Session() as client:
        client.headers.update({'Referer': login_url})
        response = client.get(login_url)
        html = response.content.decode("utf-8-sig")
        tokenstarttext = '<input id="csrf_token" name="csrf_token" type="hidden" value="'
        start = html.index(tokenstarttext)
        length = html[start:].index('">')
        token = html[start + len(tokenstarttext):start + length]
        print(token)
        login_response = client.post(login_url, data={
            "csrf_token": token,
            "username_or_email": user,
            "password": password
        })
        if "<h2>Error</h2>" in login_response.text:
            start = login_response.text.index("<h2>Error</h2>")
            print(login_response.text[start:start+250])
            return
        response = client.get(f"https://www.factorio.com/get-download/{version}/{build}/{distro}")
    return response


response = get_latest_factorio("Test", "Test")

User avatar
vinzenz
Factorio Staff
Factorio Staff
Posts: 67
Joined: Mon Aug 02, 2021 6:45 pm
Contact:

Re: Factorio Download API now requires CAPTCHA

Post by vinzenz »

The captcha triggers on too many failed logins. Other downloaders try to replicate the games behaviour and get the token from https://wiki.factorio.com/Web_authentication_API (you'll get blocked there too if you keep trying to login with wrong info)

Be advised that these are internal APIs (-> https://wiki.factorio.com/Factorio_HTTP ... guidelines)

https://gitlab.com/moviuro/factorio-dl/ ... actorio-dl
https://github.com/narc0tiq/factorio-updater
bringing the oops to devops

lyvgbfh
Fast Inserter
Fast Inserter
Posts: 102
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: Factorio Download API now requires CAPTCHA

Post by lyvgbfh »

vinzenz wrote:
Mon Jun 20, 2022 5:55 am
The captcha triggers on too many failed logins. Other downloaders try to replicate the games behaviour and get the token from https://wiki.factorio.com/Web_authentication_API (you'll get blocked there too if you keep trying to login with wrong info)

Be advised that these are internal APIs (-> https://wiki.factorio.com/Factorio_HTTP ... guidelines)

https://gitlab.com/moviuro/factorio-dl/ ... actorio-dl
https://github.com/narc0tiq/factorio-updater
Does solving the captcha clear the block per-IP, or does it just set a cookie?

User avatar
vinzenz
Factorio Staff
Factorio Staff
Posts: 67
Joined: Mon Aug 02, 2021 6:45 pm
Contact:

Re: Factorio Download API now requires CAPTCHA

Post by vinzenz »

lyvgbfh wrote:
Mon Jun 20, 2022 8:54 am
Does solving the captcha clear the block per-IP, or does it just set a cookie?
Solving the captcha will allow you to complete a login which gives you a session cookie. Whether we require a captcha on future logins is independent from it.
bringing the oops to devops

Post Reply

Return to “Technical Help”