narc0tiq / factorio-updater

Factorio update helper for headless servers
MIT License
245 stars 48 forks source link

Get login tokens from the Factorio API when needed #16

Open narc0tiq opened 7 years ago

narc0tiq commented 7 years ago

Look into what fac does and do something similar.

Update player-data.json as needed and read it when the --user and/or --token are left out of the command line.

VRabadan commented 7 years ago

Just a question. May be this isn't the place for this, but I don't know where to ask, In the forums I didn't find anything.

How can I obtain the login token? I've looked on the specified data directory, but the player.json is missing. Is there a request I can do to the API so I can obtain the token?

Kind Regards

narc0tiq commented 7 years ago

Which Factorio (standalone, installer, Steam) do you have and where did you search? And it's not player.json, but player-data.json.

Yes, there must be an API request to obtain the token. I haven't looked into it, though.

On a brief skim of fac's source, it looks like it's a POST to https://auth.factorio.com/api-login with the data username=bla&password=1234. So this worked:

[narc@odin ~]% curl -X POST --data 'username=Narc&password=<ellided>' https://auth.factorio.com/api-login
["f8f4<ellided>"]
VRabadan commented 7 years ago

Thanks for the Tip, I managed to get my headless server running and published. Don't know why the file "player-data.json" is missing tho.

Kind Regards

narc0tiq commented 7 years ago

Well, without answering the original questions (which Factorio, where did you search?), I can't help you. The README has a section specifically for finding the file, but I assume you've read that already.

Regardless, I'm glad you managed to get it some other way.

Dev-iL commented 6 years ago

BTW, the web-auth API is documented here.