Class: Gpsoauth::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/gpsoauth/connection.rb

Constant Summary collapse

AUTH_URL =
"https://android.clients.google.com/auth"
USER_AGENT =
"gpsoauth/gpsoauth"
B64_KEY_7_3_29 =

The key is distirbuted with Google Play Services. This one is from version 7.3.29.

"AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6p" \
"rwgi3iJIZdodyhKZQrNWp5nKJ3srRXcUW+F1BD3baEVGcmEgqaLZUNBjm057pKRI16kB0" \
"YppeGx5qIQ5QjKzsR8ETQbKLNWgRY0QRNVz34kMJR3P/LgHax/6rmf5AAAAAwEAAQ==".b

Instance Method Summary collapse

Constructor Details

#initialize(android_id, service = nil, device_country = nil, operator_country = nil, lang = nil, sdk_version = nil) ⇒ Connection



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gpsoauth/connection.rb', line 12

def initialize(android_id, service = nil, device_country = nil,
               operator_country = nil, lang = nil, sdk_version = nil)

  @android_id = android_id

  @service = service || "ac2dm"
  @device_country = device_country || "us"
  @operator_country = operator_country || "us"
  @lang = lang || "en"
  @sdk_version = sdk_version || 17
end

Instance Method Details

#master_login(email, password) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gpsoauth/connection.rb', line 24

def (email, password)
  android_key = Google::key_from_b64(B64_KEY_7_3_29)

  data = {
    accountType: "HOSTED_OR_GOOGLE",
    Email: email,
    has_permission: 1,
    add_account: 1,
    # @TODO Finish password encryption
    # EncryptedPasswd: Google::signature(email, password, android_key)
    Passwd: password,
    service: @service,
    source: "android",
    androidId: @android_id,
    device_country:  @device_country,
    operatorCountry: @operator_country,
    lang: @lang,
    sdk_version: @sdk_version
  }

  auth_request(data)
end

#oauth(email, master_token, service, app, client_signature) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gpsoauth/connection.rb', line 47

def oauth(email, master_token, service, app, client_signature)
  data = {
    accountType: "HOSTED_OR_GOOGLE",
    Email: email,
    has_permission: 1,
    EncryptedPasswd: master_token,
    source: "android",
    androidId: @android_id,
    device_country:  @device_country,
    operatorCountry: @operator_country,
    lang: @lang,
    sdk_version: @sdk_version,
    service: service,
    app: app,
    client_sig: client_signature
  }

  auth_request(data)
end