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?
Mod Portal API authentication
- Haxton Fale
- Burner Inserter
- Posts: 9
- Joined: Sat Mar 19, 2016 12:59 pm
- Contact:
- AlyxDeLunar
- Fast Inserter
- Posts: 105
- Joined: Mon Dec 22, 2014 7:32 pm
- Contact:
Re: Mod Portal API authentication
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}
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}
Last edited by AlyxDeLunar on Thu Sep 15, 2016 4:18 pm, edited 1 time in total.
- Haxton Fale
- Burner Inserter
- Posts: 9
- Joined: Sat Mar 19, 2016 12:59 pm
- Contact:
Re: Mod Portal API authentication
Thanks, this will be useful for testing!
A proper auth API would definitely be better...
A proper auth API would definitely be better...
Re: Mod Portal API authentication
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
viewtopic.php?f=137&t=29509
Has a the authentication login implemented at: https://github.com/mickael9/fac/blob/master/fac/api.py
- Haxton Fale
- Burner Inserter
- Posts: 9
- Joined: Sat Mar 19, 2016 12:59 pm
- Contact:
Re: Mod Portal API authentication
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.
I hope there will be some official docs for all the APIs by the time game comes out.
Re: Mod Portal API authentication
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!?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 feel stupid now, I should have googled earlier)
- Haxton Fale
- Burner Inserter
- Posts: 9
- Joined: Sat Mar 19, 2016 12:59 pm
- Contact:
Re: Mod Portal API authentication
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
You can not authenticate using the password. However, you can get the token from the password by sending a POST request toAlyxDeLunar wrote:I'm not aware of how to authenticate with the server given just a username and password
Code: Select all
https://auth.factorio.com/api-login
Code: Select all
require_game_ownership=True&username=<username>&password=<password>