Web authentication API: Difference between revisions
Jump to navigation
Jump to search
(add category) |
(Update possible return codes and values) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<div align="center" class="stub">'''Category:''' [[Factorio_HTTP_API_usage_guidelines#Internal|Internal API]]</div> | |||
'''Category:''' [ | |||
Factorio's Web Authentication API endpoint gives you a token in exchange for your username and password, which is used by several other Factorio web API endpoints. The authentication endpoint is located at: | Factorio's Web Authentication API endpoint gives you a token in exchange for your username and password, which is used by several other Factorio web API endpoints. The authentication endpoint is located at: | ||
Line 6: | Line 5: | ||
<code>https://auth.factorio.com/api-login</code> | <code>https://auth.factorio.com/api-login</code> | ||
Authentication requires sending an HTTP POST request with these parameters: | Authentication requires sending an HTTP POST request (Content-Type: <code>application/x-www-form-urlencoded</code>) with these parameters: | ||
{| class="wikitable" | {| class="wikitable" | ||
| username | | username | ||
| Required. | | Required. | ||
| Account username. | | Account username or e-mail. | ||
|- | |- | ||
| password | | password | ||
Line 18: | Line 17: | ||
|- | |- | ||
| api_version | | api_version | ||
| | | Default: 1 | ||
| Currently | | Currently 6. | ||
|- | |- | ||
| require_game_ownership | | require_game_ownership | ||
| Not required. | | Not required. | ||
| If set to 'true', will fail authentication if the user account hasn't actually purchased Factorio. | | If set to 'true', will fail authentication if the user account hasn't actually purchased Factorio. | ||
|- | |||
| email_authentication_code | |||
| Not required. | |||
| If a previous login failed with <code>email-authentication-required</code>, email authentication can be completed by including the code sent to the user via mail. | |||
|} | |||
This endpoint always returns JSON encoded data. | |||
{| class="wikitable" | |||
|+ HTTP Status codes | |||
|- | |||
! API-Version | |||
! Success | |||
! Error | |||
|- | |||
! <= 3 | |||
| 200 | |||
| 401 | |||
|- | |||
! >= 4 | |||
| 200 | |||
| 200 | |||
|} | |} | ||
{| class="wikitable" | |||
|+ Success json | |||
|- | |||
! API-Version | |||
! Name | |||
! Value | |||
|- | |||
| <= 1 | |||
| [] | |||
| Array of hexadecimal encoded auth tokens | |||
|- | |||
| >= 2 | |||
| token | |||
| Auth token is a hexadecimal encoded byte string | |||
|- | |||
| >= 2 | |||
| username | |||
| The username of the logged in user. | |||
|} | |||
{| class="wikitable" | |||
|+ Error json | |||
|- | |||
! API-Version | |||
! Name | |||
! Value | |||
|- | |||
| all | |||
| data | |||
| Always empty object "{}" | |||
|- | |||
| all | |||
| error | |||
| Error codes like <code>login-failed</code> or <code>email-authentication-required</code> | |||
|- | |||
| all | |||
| message | |||
| A more detailed error message that can be shown to the user | |||
|- | |||
| <= 3 | |||
| status | |||
| Same value as the Status Code | |||
|} | |||
Clients causing a lot of errors like <code>login-failed</code> will be rate limited. | |||
[[Category:Technical]] | [[Category:Technical]] |
Latest revision as of 19:50, 3 October 2024
Category: Internal API
Factorio's Web Authentication API endpoint gives you a token in exchange for your username and password, which is used by several other Factorio web API endpoints. The authentication endpoint is located at:
https://auth.factorio.com/api-login
Authentication requires sending an HTTP POST request (Content-Type: application/x-www-form-urlencoded
) with these parameters:
username | Required. | Account username or e-mail. |
password | Required. | Account password. |
api_version | Default: 1 | Currently 6. |
require_game_ownership | Not required. | If set to 'true', will fail authentication if the user account hasn't actually purchased Factorio. |
email_authentication_code | Not required. | If a previous login failed with email-authentication-required , email authentication can be completed by including the code sent to the user via mail.
|
This endpoint always returns JSON encoded data.
API-Version | Success | Error |
---|---|---|
<= 3 | 200 | 401 |
>= 4 | 200 | 200 |
API-Version | Name | Value |
---|---|---|
<= 1 | [] | Array of hexadecimal encoded auth tokens |
>= 2 | token | Auth token is a hexadecimal encoded byte string |
>= 2 | username | The username of the logged in user. |
API-Version | Name | Value |
---|---|---|
all | data | Always empty object "{}" |
all | error | Error codes like login-failed or email-authentication-required
|
all | message | A more detailed error message that can be shown to the user |
<= 3 | status | Same value as the Status Code |
Clients causing a lot of errors like login-failed
will be rate limited.