fortniteruby 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/client.rb +45 -0
- metadata +4 -5
- data/lib/fortniteruby/client.rb +0 -44
- data/lib/fortniteruby.rb +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4372116bd0dce5aa9242e4dd33e7cfa49cbed02af6e67dfb5a05dabc9500a3e
|
|
4
|
+
data.tar.gz: 307b04c436df5754d61964546ec5e24a3065754f68ce5758af2c179952078039
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cadddc117bb098eee61defb6b9a1871aabb47ac28908692a140a0875c58a4a8787fb1e30d5fc5161637287501a6e18abc6f15a290a5ac11928392dd0ee151eb9
|
|
7
|
+
data.tar.gz: 7e4c0343d620affea16e8f0841e1ce8ec8d0797b5858d888da9d4551f434d196098c1f62acd0a65dc3664831cc138d30a1d28f95a0b85bbe72f371ae35abd9eb
|
data/lib/client.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
3
|
+
class FortniteClient
|
|
4
|
+
def authenticate()
|
|
5
|
+
# Function to authenticate with the Epic Games API through exchange code.
|
|
6
|
+
login = HTTParty.post(
|
|
7
|
+
"https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token",
|
|
8
|
+
:headers => {
|
|
9
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
|
10
|
+
"Authorization" => "basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ="
|
|
11
|
+
},
|
|
12
|
+
:body => {
|
|
13
|
+
"grant_type" => "exchange_code",
|
|
14
|
+
"exchange_code" => @_exchange_code
|
|
15
|
+
},
|
|
16
|
+
# :debug_output => $stdout
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
@display_name = JSON.parse(login.body)['displayName']
|
|
20
|
+
@access_token = JSON.parse(login.body)['access_token']
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def initialize(exchange_code=nil)
|
|
24
|
+
if exchange_code == nil # Prompts an input for the exchange code if none is provided.
|
|
25
|
+
puts 'Please enter an exchange code:'
|
|
26
|
+
exchange_code = gets.chomp
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
@_exchange_code = exchange_code
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Private attributes (not intended to be used outside of the object itself).
|
|
33
|
+
attr_accessor :_exchange_code
|
|
34
|
+
|
|
35
|
+
# Public attributes.
|
|
36
|
+
attr_accessor :display_name
|
|
37
|
+
attr_accessor :access_token
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
client = FortniteClient.new(exchange_code="8ecd0b354ced4620999dc28aa77f1554")
|
|
41
|
+
client.authenticate()
|
|
42
|
+
|
|
43
|
+
puts client.display_name
|
|
44
|
+
puts client.access_token
|
|
45
|
+
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fortniteruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xMistt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-05-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -30,9 +30,8 @@ executables: []
|
|
|
30
30
|
extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
|
32
32
|
files:
|
|
33
|
-
- lib/
|
|
34
|
-
|
|
35
|
-
homepage: https://github.com/xMistt/FortniteRuby/
|
|
33
|
+
- lib/client.rb
|
|
34
|
+
homepage: https://github.com/xMistt/fortniteruby/
|
|
36
35
|
licenses: []
|
|
37
36
|
metadata: {}
|
|
38
37
|
post_install_message:
|
data/lib/fortniteruby/client.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
require 'httparty'
|
|
2
|
-
|
|
3
|
-
class FortniteClient
|
|
4
|
-
def initialize(email, password)
|
|
5
|
-
csrf = HTTParty.get('https://www.epicgames.com/id/api/csrf')
|
|
6
|
-
cookie = "EPIC_FUNNEL_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[1]}; EPIC_DEVICE=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[24]}; EPIC_SESSION_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[47]}; XSRF-TOKEN=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[54]}; EPIC_SSO_SESSION=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[59]}"
|
|
7
|
-
|
|
8
|
-
headers = {"x-xsrf-token" => csrf.headers['Set-Cookie'].split(/[\s=;]/)[54], "Cookie" => cookie}
|
|
9
|
-
body = {'email': email, 'password': password, 'rememberMe': false}
|
|
10
|
-
login = HTTParty.post("https://www.epicgames.com/id/api/login", :headers => headers, :body => body)
|
|
11
|
-
cookie = "EPIC_FUNNEL_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[1]}; EPIC_DEVICE=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[24]}; EPIC_SESSION_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[47]}; XSRF-TOKEN=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[54]}; EPIC_SSO_SESSION=#{login.headers['Set-Cookie'].split(/[\s=;]/)[1]}"
|
|
12
|
-
|
|
13
|
-
headers = {"x-xsrf-token" => csrf.headers['Set-Cookie'].split(/[\s=;]/)[54], "Cookie" => cookie}
|
|
14
|
-
exchange = HTTParty.get('https://www.epicgames.com/id/api/exchange', :headers => headers)
|
|
15
|
-
|
|
16
|
-
headers = {"Authorization" => 'basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE='}
|
|
17
|
-
body = {'grant_type': 'exchange_code', 'token_type': 'eg1', 'exchange_code': JSON.parse(exchange.body)['code']}
|
|
18
|
-
token = HTTParty.post("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token", :headers => headers, :body => body)
|
|
19
|
-
@launcherauth = JSON.parse(token.body)['access_token']
|
|
20
|
-
|
|
21
|
-
headers = {"Authorization" => "Bearer #{JSON.parse(token.body)['access_token']}"}
|
|
22
|
-
fortniteExchange = HTTParty.get("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange", :headers => headers)
|
|
23
|
-
|
|
24
|
-
headers = {"Authorization" => 'basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ='}
|
|
25
|
-
body = {'grant_type': 'exchange_code', 'token_type': 'eg1', 'exchange_code': JSON.parse(fortniteExchange.body)['code']}
|
|
26
|
-
fortniteToken = HTTParty.post("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token", :headers => headers, :body => body)
|
|
27
|
-
|
|
28
|
-
headers = {"Authorization" => "bearer #{JSON.parse(fortniteToken.body)['access_token']}"}
|
|
29
|
-
account = HTTParty.get("https://account-public-service-prod03.ol.epicgames.com/account/api/public/account/#{JSON.parse(fortniteToken.body)['account_id']}", :headers => headers)
|
|
30
|
-
@token = JSON.parse(fortniteToken.body)['access_token']
|
|
31
|
-
|
|
32
|
-
body = JSON.parse(account.body)
|
|
33
|
-
|
|
34
|
-
body.each do |name, value|
|
|
35
|
-
instance_variable_set("@#{name}", value)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
attr_reader :displayName
|
|
41
|
-
attr_reader :id
|
|
42
|
-
attr_reader :token
|
|
43
|
-
|
|
44
|
-
end
|
data/lib/fortniteruby.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require_relative 'fortniteruby/client.rb'
|