Page 1 of 1

Mod Portal API authentication

Posted: Wed Sep 14, 2016 8:23 pm
by Haxton Fale
So I found there's a nifty mod portal API, and it would be tremendously helpful for automating mod updates on my server. However, download links require me to log in first. Is there a way to log in via some tool?
Can we expect the mod portal API to be documented in near future?

Re: Mod Portal API authentication

Posted: Thu Sep 15, 2016 2:03 am
by AlyxDeLunar
I'm not aware of how to authenticate with the server given just a username and password (it was a painful few days trying to figure it out). However, if you've already authenticated with the server (such as through the game), you can use the username and token (it's saved in a json file) to make downloads. So just like this:

1) Get the service-username/service-token from the game (located in player-data.json, should be in the appData folder).
2) Get the download link of the mod you want, and append the user/token to it (it's a get request). It should look like this:
https://mods.factorio.com/${mod download link}?username=${playerUsername}&token=${playerToken}

Re: Mod Portal API authentication

Posted: Thu Sep 15, 2016 9:25 am
by Haxton Fale
Thanks, this will be useful for testing!

A proper auth API would definitely be better...

Re: Mod Portal API authentication

Posted: Tue Sep 27, 2016 10:16 am
by Daid
Just for reference, I noticed that the commandline mod tool:
viewtopic.php?f=137&t=29509

Has a the authentication login implemented at: https://github.com/mickael9/fac/blob/master/fac/api.py

Re: Mod Portal API authentication

Posted: Tue Sep 27, 2016 1:22 pm
by Haxton Fale
Well spotted. Thanks a lot! It will definitely be very helpful.

I hope there will be some official docs for all the APIs by the time game comes out.

Re: Mod Portal API authentication

Posted: Fri Oct 21, 2016 6:41 am
by Danacus
AlyxDeLunar wrote:I'm not aware of how to authenticate with the server given just a username and password (it was a painful few days trying to figure it out). However, if you've already authenticated with the server (such as through the game), you can use the username and token (it's saved in a json file) to make downloads. So just like this:

1) Get the service-username/service-token from the game (located in player-data.json, should be in the appData folder).
2) Get the download link of the mod you want, and append the user/token to it (it's a get request). It should look like this:
https://mods.factorio.com/${mod download link}?username=${playerUsername}&token=${playerToken}
I was trying everything, like putting a browser in my program to let the user login and now your telling me it's as easy as this!?
(I feel stupid now, I should have googled earlier)

Re: Mod Portal API authentication

Posted: Fri Oct 21, 2016 7:52 am
by Haxton Fale
To be fair, the browser is probably a little bit more reliable than undocumented APIs that can change on a moment's notice

Re: Mod Portal API authentication

Posted: Thu Oct 27, 2016 10:37 am
by Artentus
AlyxDeLunar wrote:I'm not aware of how to authenticate with the server given just a username and password
You can not authenticate using the password. However, you can get the token from the password by sending a POST request to

Code: Select all

https://auth.factorio.com/api-login
with this content:

Code: Select all

require_game_ownership=True&username=<username>&password=<password>
This way you don't need to rely on the user being logged in with Factorio.