gpsoauth 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +6 -4
- data/gpsoauth.gemspec +3 -1
- data/lib/gpsoauth.rb +1 -2
- data/lib/gpsoauth/{connection.rb → client.rb} +2 -4
- data/lib/gpsoauth/google.rb +30 -13
- data/lib/gpsoauth/version.rb +1 -1
- metadata +33 -6
- data/lib/gpsoauth/utility.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eaebe898412ce66cec93768814c6e969a52a7bb
|
4
|
+
data.tar.gz: d4610c0b873235e30161dee5b87cc716849b9b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99bc53141aff810f80721186e8e629f87fac3d25831946bbb639702e191a12d46ccf4f2c1e7dccd158ba38a993023fa117f19d2175489f595613e228934ae3a4
|
7
|
+
data.tar.gz: 4f9222a04638f17c13a3fb48a048eb6e0d234c935ac97c3d9fb34f30f7db6c9aac0c42547416dc4429d64e5d3087892216a3eb43a6525cc6b005807972e5bf70
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Gpsoauth
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/gpsoauth.svg)](https://badge.fury.io/rb/gpsoauth)
|
4
|
+
|
3
5
|
A Ruby client library for Google Play Services OAuth
|
4
6
|
|
5
7
|
A port of the Python library [gpsoauth](https://github.com/simon-weber/gpsoauth) by [Simon Weber](https://github.com/simon-weber)
|
@@ -18,15 +20,15 @@ And then execute:
|
|
18
20
|
|
19
21
|
$ bundle
|
20
22
|
|
21
|
-
|
23
|
+
Or install it yourself as:
|
22
24
|
|
23
|
-
|
25
|
+
$ gem install gpsoauth
|
24
26
|
|
25
27
|
## Usage
|
26
28
|
|
27
|
-
Instantiate a Gpsoauth
|
29
|
+
Instantiate a Gpsoauth client. This requires an Android ID:
|
28
30
|
|
29
|
-
g = Gpsoauth::
|
31
|
+
g = Gpsoauth::Client.new(android_id, [service, device_country, operator_country, lang, sdk_version])
|
30
32
|
|
31
33
|
Perform 'master login' with email/password:
|
32
34
|
|
data/gpsoauth.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.11"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.9"
|
26
|
+
spec.add_development_dependency "byebug", "~> 9.0"
|
25
27
|
|
26
|
-
spec.add_dependency "httparty", "~> 0.
|
28
|
+
spec.add_dependency "httparty", "~> 0.14"
|
27
29
|
end
|
data/lib/gpsoauth.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Gpsoauth
|
2
|
-
class
|
2
|
+
class Client
|
3
3
|
AUTH_URL = "https://android.clients.google.com/auth"
|
4
4
|
USER_AGENT = "gpsoauth/gpsoauth"
|
5
5
|
|
@@ -29,9 +29,7 @@ module Gpsoauth
|
|
29
29
|
Email: email,
|
30
30
|
has_permission: 1,
|
31
31
|
add_account: 1,
|
32
|
-
|
33
|
-
# EncryptedPasswd: Google::signature(email, password, android_key)
|
34
|
-
Passwd: password,
|
32
|
+
EncryptedPasswd: Google::signature(email, password, android_key),
|
35
33
|
service: @service,
|
36
34
|
source: "android",
|
37
35
|
androidId: @android_id,
|
data/lib/gpsoauth/google.rb
CHANGED
@@ -17,26 +17,43 @@ module Gpsoauth
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.signature(email, password, key)
|
20
|
-
|
21
|
-
struct = key_to_struct(key)
|
22
|
-
signature.push Digest::SHA1.hexdigest(struct)[0,4]
|
23
|
-
|
24
|
-
# @TODO Encryptedpasswd notes:
|
20
|
+
# Encryption scheme deconstructed here:
|
25
21
|
# http://codedigging.com/blog/2014-06-09-about-encryptedpasswd/
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
|
23
|
+
struct = key_to_struct(key).pack('c*')
|
24
|
+
first_four_bytes_sha1 = OpenSSL::Digest::SHA1.digest(struct)[0...4]
|
25
|
+
|
26
|
+
encrypted_login_password = key.public_encrypt(
|
27
|
+
email + "\x00" + password,
|
28
|
+
OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING
|
29
|
+
)
|
30
|
+
|
31
|
+
signature = "\x00" + first_four_bytes_sha1 + encrypted_login_password
|
32
|
+
Base64.urlsafe_encode64(signature)
|
31
33
|
end
|
32
34
|
|
33
35
|
private
|
34
36
|
|
37
|
+
def self.long_to_bytes(key)
|
38
|
+
arr = []
|
39
|
+
key, mod = key.divmod(256)
|
40
|
+
|
41
|
+
while mod > 0 || key > 0
|
42
|
+
arr << mod
|
43
|
+
key, mod = key.divmod(256)
|
44
|
+
end
|
45
|
+
|
46
|
+
arr = arr.reverse
|
47
|
+
end
|
48
|
+
|
35
49
|
def self.key_to_struct(key)
|
36
|
-
|
37
|
-
|
50
|
+
mod_buffer = "\x00\x00\x00\x80".unpack('C*')
|
51
|
+
exponent_buffer = "\x00\x00\x00\x03".unpack('C*')
|
52
|
+
|
53
|
+
mod = long_to_bytes(key.n.to_i)
|
54
|
+
exponent = long_to_bytes(key.e.to_i)
|
38
55
|
|
39
|
-
|
56
|
+
mod_buffer + mod + exponent_buffer + exponent
|
40
57
|
end
|
41
58
|
end
|
42
59
|
end
|
data/lib/gpsoauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpsoauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Mytko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,48 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '9.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '9.0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: httparty
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
75
|
+
version: '0.14'
|
48
76
|
type: :runtime
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
82
|
+
version: '0.14'
|
55
83
|
description: |-
|
56
84
|
A Ruby client library for Google Play Services OAuth.
|
57
85
|
A port of the Python library gpsoauth by Simon Weber
|
@@ -68,10 +96,9 @@ files:
|
|
68
96
|
- README.md
|
69
97
|
- gpsoauth.gemspec
|
70
98
|
- lib/gpsoauth.rb
|
71
|
-
- lib/gpsoauth/
|
99
|
+
- lib/gpsoauth/client.rb
|
72
100
|
- lib/gpsoauth/exceptions.rb
|
73
101
|
- lib/gpsoauth/google.rb
|
74
|
-
- lib/gpsoauth/utility.rb
|
75
102
|
- lib/gpsoauth/version.rb
|
76
103
|
homepage: http://github.com/bryanmytko/gpsoauth
|
77
104
|
licenses:
|
data/lib/gpsoauth/utility.rb
DELETED