Class: FactorioMods::Api::WebAuthentication
- Inherits:
-
Object
- Object
- FactorioMods::Api::WebAuthentication
- Defined in:
- lib/factorio_mods/api/web_authentication.rb
Overview
Information taken from wiki.factorio.com/Web_authentication_API
Constant Summary collapse
- BASE_URL =
'https://auth.factorio.com'.freeze
- API_VERSION =
2
Class Method Summary collapse
- .login(username, password, version = API_VERSION, ownership = false) ⇒ Object
- .token ⇒ Object
- .username ⇒ Object
Class Method Details
.login(username, password, version = API_VERSION, ownership = false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/factorio_mods/api/web_authentication.rb', line 15 def self.login(username, password, version = API_VERSION, ownership = false) resp = Net::HTTP.post_form(URI(BASE_URL + '/api-login'), username: username, password: password, api_version: version, require_game_ownership: ownership.to_s) resp.value data = JSON.parse(resp.body, symbolize_names: true) @username = data[:username] @token = data[:token] end |
.token ⇒ Object
11 12 13 |
# File 'lib/factorio_mods/api/web_authentication.rb', line 11 def self.token @token end |
.username ⇒ Object
7 8 9 |
# File 'lib/factorio_mods/api/web_authentication.rb', line 7 def self.username @username end |