Mod Portal API authentication

Enhance your gameplay with these tools. This category is also the right place for tools useful for modders.
Mod databases, calculators, cheatsheets, multiplayer, scripts, libs and other useful stuff that is not strictly in-game mods.
Post Reply
User avatar
Haxton Fale
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Mar 19, 2016 12:59 pm
Contact:

Mod Portal API authentication

Post 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?

User avatar
AlyxDeLunar
Fast Inserter
Fast Inserter
Posts: 105
Joined: Mon Dec 22, 2014 7:32 pm
Contact:

Re: Mod Portal API authentication

Post 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}
Last edited by AlyxDeLunar on Thu Sep 15, 2016 4:18 pm, edited 1 time in total.
Sometimes humorous, usually congenial. Always Alyx.

My Stuff:
Lunar's Factorio Mod Manager

User avatar
Haxton Fale
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Mar 19, 2016 12:59 pm
Contact:

Re: Mod Portal API authentication

Post by Haxton Fale »

Thanks, this will be useful for testing!

A proper auth API would definitely be better...

Daid
Fast Inserter
Fast Inserter
Posts: 163
Joined: Sun Jul 03, 2016 7:42 am
Contact:

Re: Mod Portal API authentication

Post 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

User avatar
Haxton Fale
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Mar 19, 2016 12:59 pm
Contact:

Re: Mod Portal API authentication

Post 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.

Danacus
Inserter
Inserter
Posts: 29
Joined: Sun Sep 18, 2016 5:25 pm
Contact:

Re: Mod Portal API authentication

Post 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)

User avatar
Haxton Fale
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Mar 19, 2016 12:59 pm
Contact:

Re: Mod Portal API authentication

Post 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

Artentus
Filter Inserter
Filter Inserter
Posts: 307
Joined: Sat Sep 24, 2016 8:16 pm
Contact:

Re: Mod Portal API authentication

Post 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.

Post Reply

Return to “Tools”