How to upload a new release to the mod-portal (using python)

A place to talk about the official Factorio mod portal (https://mods.factorio.com)
Post Reply
Karoschl
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Oct 05, 2019 3:37 pm
Contact:

How to upload a new release to the mod-portal (using python)

Post by Karoschl »

Hi,
I would like to use python to upload a updated mod release to the mod portal.
Assuming the package is valid and does not exist on the portal i would expect the following steps to work:

0. Using a single session
1. log in at https://auth.factorio.com/api-login and obtain an auth_token
2. log into mod portal https://mods.factorio.com/login
3. Get upload token https://mods.factorio.com/mod/myModName/downloads/edit (fails, I get another login page)

... is there an working example or wiki page on this topic somewhere ?

Edit: Full Non-working example availiable at https://github.com/nicolas-lang/Factori ... er/test.py
Last edited by Karoschl on Sat Jun 12, 2021 10:36 pm, edited 2 times in total.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: [Question] How to upload a new release to the mod-portal (using python)

Post by Xorimuth »

There isn’t an official API for this, but there are several GitHub actions and a VSCode extension that may contain what you are looking for.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Karoschl
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Oct 05, 2019 3:37 pm
Contact:

Re: [Question] How to upload a new release to the mod-portal (using python)

Post by Karoschl »

I started doing my own code since i failed to get the preexisting stuff to work.
I initially started using https://github.com/Roang-zero1/factorio ... ase-action but that failes with strange errors related to the cssrf token

Code: Select all

sh: id="csrf_token": unknown operand
parse error: Invalid numeric literal at line 1, column 10
sh: null: unknown operand
after some checking of the various examples i found and to me it seems all kind of the same and also somehow different, and none of the ones I tested worked.

Based on that I started looking for documentation and was discouraged by https://wiki.factorio.com/Web_authentication_API

At the moment I am mostly confused by the information I have found: can you possible refer me to an example of a github action that is currently confirmed working ?

Bilka
Factorio Staff
Factorio Staff
Posts: 3130
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [Question] How to upload a new release to the mod-portal (using python)

Post by Bilka »

I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Karoschl
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Oct 05, 2019 3:37 pm
Contact:

Re: [Question] How to upload a new release to the mod-portal (using python)

Post by Karoschl »

Thanks a lot Bilka, that is a good place to start!

The "api" still looks it bit scary with all that html-regex, but i can work with that :D

I'll provide an update when i run into the next issue or when it works !

Karoschl
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Oct 05, 2019 3:37 pm
Contact:

Re: [Question] How to upload a new release to the mod-portal (using python)

Post by Karoschl »

I got it working, just some cleanup and I'll share the code.

Thanks a lot

Karoschl
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Oct 05, 2019 3:37 pm
Contact:

Re: [Question] How to upload a new release to the mod-portal (using python)

Post by Karoschl »

Example code and demo mod to showcase deployment using python & github workflows.
Very similiar to examples by Roang-zero1, Nexela, and Shane Madden but based on python and with slightly more logging.

Post Reply

Return to “Mod portal Discussion”