Page 1 of 1

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

Posted: Fri Jun 11, 2021 2:49 pm
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

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

Posted: Fri Jun 11, 2021 4:45 pm
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.

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

Posted: Fri Jun 11, 2021 6:59 pm
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 ?

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

Posted: Fri Jun 11, 2021 7:34 pm
by Bilka

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

Posted: Fri Jun 11, 2021 8:40 pm
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 !

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

Posted: Sat Jun 12, 2021 9:43 am
by Karoschl
I got it working, just some cleanup and I'll share the code.

Thanks a lot

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

Posted: Sat Jun 12, 2021 4:17 pm
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.