In other languages:

Web authentication API: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
(Update to api_version 4)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Technical]]
{{Languages}}
<div align="center" class="stub">'''Category:''' [[Factorio_HTTP_API_usage_guidelines#Internal|Internal API]]</div>
 
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 8: Line 10:
{| class="wikitable"
{| class="wikitable"
| username
| username
| Account username.
| Required.
| Account username or e-mail.
|-
|-
| password
| password
| Required.
| Account password.
| Account password.
|-
| api_version
| (Technically) not required. API responses will be different than described on this page when not set to 4.
| Currently 4.
|-
| 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 <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. If authentication was successful, it will return an HTTP status code of 200 with a JSON list containing a single item: the auth token. The auth token seems to always be a hexadecimal encoded 15-byte string of random bytes.
This endpoint always returns JSON encoded data. If authentication was successful, it will return an HTTP status code of 200 with a JSON object:


TODO: exceptions and stuffs.
{| class="wikitable"
| token
| Auth token is a hexadecimal encoded byte string
|-
| username
| The username of the logged in user.
 
|}
 
On non-200 status codes, the response can be JSON encoded and provide more details about the problem:
 
{| class="wikitable"
| error
| Error codes like <code>login-failed</code> or <code>email-authentication-required</code>
|-
| message
| A more detailed error message that can be shown to the user
 
|}
 
Clients causing a lot of errors like <code>login-failed</code> will be rate limited.
 
[[Category:Technical]]

Latest revision as of 16:55, 7 March 2022

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 with these parameters:

username Required. Account username or e-mail.
password Required. Account password.
api_version (Technically) not required. API responses will be different than described on this page when not set to 4. Currently 4.
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. If authentication was successful, it will return an HTTP status code of 200 with a JSON object:

token Auth token is a hexadecimal encoded byte string
username The username of the logged in user.

On non-200 status codes, the response can be JSON encoded and provide more details about the problem:

error Error codes like login-failed or email-authentication-required
message A more detailed error message that can be shown to the user

Clients causing a lot of errors like login-failed will be rate limited.