Closed Arnavion closed 8 years ago
You can use -v
for requests debugging :)
I'm not having this issue, I suspect the 403 error is because your token or username is invalid (from player-data.json
)
Are you able to download mods from the game?
Anyway, I'll add some error handling so that invalid error codes are raised as HTTPError
See edit to the OP :)
Anyway, I'll add some error handling so that invalid error codes are raised as HTTPError
Yeah, that's what I was asking for. Otherwise there's the possibility a non-200 response has the same content length as the actual mod file, and fac install
won't notice.
There's no way it wouldn't fail later in the process anyway, since the zip file is opened and info.json
is read before the zip gets saved.
Anyway, I added some proper error messages for both the "already logged in with no game ownership" and also added the require_ownership=true
parameter which the game uses on login. This is what it looks like now:
$ fac install yarm
Installing: YARM 0.7.107...
Downloading: https://mods.factorio.com/api/downloads/data/mods/187/YARM_0.7.107.zip...
Authentification error when downloading mod. Please login again.
You need a Factorio account to download mods.
Please provide your username and password to authenticate yourself.
Your username and token (NOT your password) will be stored so that you only have to enter it once
This uses the exact same method used by Factorio itself
Username [mickael9-test]:
Password (not shown):
Ownership error: Your factorio account doesn't own the game.
Please buy the game or link your Steam account if you have bought the game from Steam.
I ran
fac install hacked-splitters
and it failed with:I added a
print('%s' % req)
indownload_mod
and get<Response [403]>
. So basically the download request returned a 0-byte 403 response. You should probably also verify that the response status code is 200 beforedata = req.content
, etc(
I'm still investigating why I'm getting a 403 there at all...The 403 is because this is a new account and I haven't connected it to my Steam account yet. Logging in tomods.factorio.com
in a web browser gives meThis account doesn't have a sufficient membership. If you bought the game on Steam, you need to connect your Steam account to your factorio.com account.
)