poke-go-api 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/poke-api/auth/google.rb +28 -5
- data/lib/poke-api/auth/ptc.rb +1 -1
- data/lib/poke-api/client.rb +14 -14
- data/lib/poke-api/request_builder.rb +2 -2
- data/lib/poke-api/testing.rb +13 -13
- data/lib/poke-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62e2737346452ed25a9d5d7844df4a7389fdbd31
|
4
|
+
data.tar.gz: b7695c8567f9e12971a8e2002f5e4962d4625802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 507f26d5261a1a5257bb44c1d5c36755a825d33b1ee1ee82a00155a8596adeaec523ac77522ea053779711a4bb4e85ad8c4fd809e9a9c4175693328faba35a2a
|
7
|
+
data.tar.gz: a9554db26d2c2fce91d246d0dd1ff70d8009f4a2ec9b44c64f9caef53dfb4cf01a842abc4f38d28622f878abbc4d3e9a93b6a5c45ad0da0ec39148df56339f62
|
data/lib/poke-api/auth/google.rb
CHANGED
@@ -13,14 +13,16 @@ module Poke
|
|
13
13
|
GOOGLE_LOGIN_APP = 'com.nianticlabs.pokemongo'.freeze
|
14
14
|
GOOGLE_LOGIN_CLIENT_SIG = '321187995bc7cdc2b5fc91b11a96e2baa8602c62'.freeze
|
15
15
|
|
16
|
-
def initialize(username, password)
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
16
|
+
def initialize(username, password, refresh_token)
|
17
|
+
@refresh_token = refresh_token
|
18
|
+
@username = username
|
19
|
+
@password = password
|
20
|
+
@provider = 'google'
|
21
|
+
@expiry = 0
|
21
22
|
end
|
22
23
|
|
23
24
|
def connect
|
25
|
+
return access_token_from_refresh_token if @refresh_token
|
24
26
|
logger.debug '[>] Fetching Google access token'
|
25
27
|
|
26
28
|
token_request = perform_request('Token') do
|
@@ -38,6 +40,27 @@ module Poke
|
|
38
40
|
|
39
41
|
private
|
40
42
|
|
43
|
+
def access_token_from_refresh_token
|
44
|
+
logger.info '[>] Fetching Google access token from refresh token'
|
45
|
+
|
46
|
+
body = {
|
47
|
+
grant_type: 'refresh_token',
|
48
|
+
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
49
|
+
refresh_token: @refresh_token,
|
50
|
+
scope: 'email',
|
51
|
+
client_secret: 'NCjF1TLi2CcY6t5mt0ZveuL7',
|
52
|
+
client_id: '848232511240-73ri3t7plvk96pj4f85uj8otdat2alem.apps.googleusercontent.com',
|
53
|
+
}
|
54
|
+
|
55
|
+
resp = HTTPClient.new.post('https://accounts.google.com/o/oauth2/token', body).body
|
56
|
+
data = JSON.parse(resp)
|
57
|
+
|
58
|
+
@access_token = data['id_token']
|
59
|
+
@expiry = data['expires_in'].to_i + Helpers.fetch_time(ms: false)
|
60
|
+
|
61
|
+
raise 'Invalid refresh token' unless data['id_token']
|
62
|
+
end
|
63
|
+
|
41
64
|
def perform_request(method)
|
42
65
|
response = yield
|
43
66
|
|
data/lib/poke-api/auth/ptc.rb
CHANGED
@@ -14,7 +14,7 @@ module Poke
|
|
14
14
|
PTC_LOGIN_OAUTH = 'https://sso.pokemon.com/sso/oauth2.0/accessToken'.freeze
|
15
15
|
PTC_LOGIN_CLIENT_SECRET = 'w8ScCUXJQc6kXKw8FiOhd8Fixzht18Dq3PEVkUCP5ZPxtgyWsbTvWHFLm2wNY0JR'.freeze
|
16
16
|
|
17
|
-
def initialize(username, password)
|
17
|
+
def initialize(username, password, _refresh_token)
|
18
18
|
@username = username
|
19
19
|
@password = password
|
20
20
|
@provider = 'ptc'
|
data/lib/poke-api/client.rb
CHANGED
@@ -2,36 +2,32 @@ module Poke
|
|
2
2
|
module API
|
3
3
|
class Client
|
4
4
|
include Logging
|
5
|
-
attr_accessor :
|
6
|
-
|
5
|
+
attr_accessor :endpoint, :sig_loaded, :refresh_token,
|
6
|
+
:lat, :lng, :alt, :http_client, :ticket
|
7
|
+
attr_reader :sig_path, :auth
|
7
8
|
|
8
9
|
def initialize
|
9
|
-
@auth = nil
|
10
10
|
@endpoint = 'https://pgorelease.nianticlabs.com/plfe/rpc'
|
11
11
|
@reqs = []
|
12
12
|
@lat = 0
|
13
13
|
@lng = 0
|
14
|
-
@alt =
|
14
|
+
@alt = rand(1..9)
|
15
15
|
@ticket = Auth::Ticket.new
|
16
|
-
@sig_path = nil
|
17
16
|
@sig_loaded = false
|
18
17
|
end
|
19
18
|
|
20
19
|
def login(username, password, provider)
|
21
20
|
@username, @password, @provider = username, password, provider.upcase
|
22
|
-
|
23
21
|
raise Errors::InvalidProvider, provider unless %w(PTC GOOGLE).include?(@provider)
|
24
|
-
logger.info "[+] Logging in user: #{username}"
|
25
22
|
|
26
23
|
begin
|
27
|
-
@auth = Auth.const_get(@provider).new(username, password)
|
24
|
+
@auth = Auth.const_get(@provider).new(@username, @password, @refresh_token)
|
28
25
|
@auth.connect
|
29
26
|
rescue StandardError => ex
|
30
27
|
raise Errors::LoginFailure.new(@provider, ex)
|
31
28
|
end
|
32
29
|
|
33
|
-
|
34
|
-
call
|
30
|
+
initialize_ticket
|
35
31
|
logger.info "[+] Login with #{@provider} Successful"
|
36
32
|
end
|
37
33
|
|
@@ -40,7 +36,7 @@ module Poke
|
|
40
36
|
raise Errors::NoRequests if @reqs.empty?
|
41
37
|
|
42
38
|
check_expiry
|
43
|
-
req = RequestBuilder.new(@auth, [@lat, @lng, @alt], @endpoint)
|
39
|
+
req = RequestBuilder.new(@auth, [@lat, @lng, @alt], @endpoint, @http_client)
|
44
40
|
|
45
41
|
begin
|
46
42
|
resp = req.request(@reqs, self)
|
@@ -67,9 +63,8 @@ module Poke
|
|
67
63
|
pos = Poke::API::Helpers.get_position(loc).first
|
68
64
|
logger.info "[+] Given location: #{pos.address}"
|
69
65
|
|
70
|
-
logger.info "[+] Lat/Long: #{pos.latitude}, #{pos.longitude}"
|
71
|
-
@lat = pos.latitude
|
72
|
-
@lng = pos.longitude
|
66
|
+
logger.info "[+] Lat/Long/Alt: #{pos.latitude}, #{pos.longitude}"
|
67
|
+
@lat, @lng = pos.latitude, pos.longitude
|
73
68
|
end
|
74
69
|
|
75
70
|
def store_lat_lng(lat, lng)
|
@@ -84,6 +79,11 @@ module Poke
|
|
84
79
|
|
85
80
|
private
|
86
81
|
|
82
|
+
def initialize_ticket
|
83
|
+
get_hatched_eggs
|
84
|
+
call
|
85
|
+
end
|
86
|
+
|
87
87
|
def check_expiry
|
88
88
|
unless @ticket.has_ticket?
|
89
89
|
now = Helpers.fetch_time(ms: false)
|
@@ -6,12 +6,12 @@ module Poke
|
|
6
6
|
include Logging
|
7
7
|
attr_reader :position, :start_time
|
8
8
|
|
9
|
-
def initialize(auth, pos, endpoint)
|
9
|
+
def initialize(auth, pos, endpoint, http_client)
|
10
10
|
@access_token = auth.access_token
|
11
11
|
@provider = auth.provider
|
12
12
|
@endpoint = endpoint
|
13
13
|
@position = pos
|
14
|
-
@client = HTTPClient.new
|
14
|
+
@client = http_client ? http_client : HTTPClient.new
|
15
15
|
@start_time = Helpers.fetch_time
|
16
16
|
end
|
17
17
|
|
data/lib/poke-api/testing.rb
CHANGED
@@ -27,22 +27,22 @@ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
27
27
|
|
28
28
|
#Poke::API::Logging.log_level = :DEBUG
|
29
29
|
client = Poke::API::Client.new
|
30
|
-
client.
|
31
|
-
|
32
|
-
client.store_location('
|
33
|
-
client.login('
|
30
|
+
#client.refresh_token = "1/QyOAeM7043LCkvyFfm61MXWV9UOBPutLwuLbjePhqPw"
|
31
|
+
client.activate_signature('C:\encrypt64bit.dll')
|
32
|
+
client.store_location('Glasgow')
|
33
|
+
client.login('sof2er@gmail.com', 'kidureallypwnme', 'google')
|
34
34
|
|
35
35
|
client.get_player
|
36
36
|
client.call
|
37
37
|
#Get cells
|
38
|
-
|
38
|
+
cell_ids = Poke::API::Helpers.get_cells(client.lat, client.lng)
|
39
39
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
# Construct map objects call
|
41
|
+
client.get_map_objects(
|
42
|
+
latitude: client.lat,
|
43
|
+
longitude: client.lng,
|
44
|
+
since_timestamp_ms: [0] * cell_ids.length,
|
45
|
+
cell_id: cell_ids
|
46
|
+
)
|
47
47
|
|
48
|
-
|
48
|
+
p client.call
|
data/lib/poke-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poke-go-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nabeel Amjad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|