-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpsoauth.rb
62 lines (57 loc) · 2.21 KB
/
gpsoauth.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "gpsoauth/version"
require "gpsoauth/google"
require "gpsoauth/utilities"
require "base64"
require "openssl"
require "httparty"
module Gpsoauth
class Auth
class << self
B64_KEY = ("AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6prwgi3iJIZdodyhKZQrNWp5nKJ3srRXcUW+F1BD3baEVGcmEgqaLZUNBjm057pKRI16kB0YppeGx5qIQ5QjKzsR8ETQbKLNWgRY0QRNVz34kMJR3P/LgHax/6rmf5AAAAAwEAAQ==")
ANDROID_KEY = Google.keyFromb64(B64_KEY)
AUTH_URL = 'https://android.clients.google.com/auth'
USER_AGENT = "gpsoauth/1.0.0"
@@cookie = ""
def performAuthRequest(data, cookie = @@cookie)
response = HTTParty.post(AUTH_URL, body: data, headers: {'User-Agent' => USER_AGENT, 'Cookie' => cookie})
@@cookies = response.headers['Set-Cookie'] if response.headers['Set-Cookie']
return Google.parseAuthResponse(response.body)
end
def performMasterLogin(email, password, android_id, service = 'ac2dm', device_country = 'us', operatorCountry = 'us', lang = 'en', sdk_version = 17)
data = {
'accountType': 'HOSTED_OR_GOOGLE',
'Email': email,
'has_permission': 1,
'add_account': 1,
'EncryptedPasswd': Google.signature(email, password, ANDROID_KEY),
'service': service,
'source': 'android',
'androidId': android_id,
'device_country': device_country,
'operatorCountry': device_country,
'lang': lang,
'sdk_version': sdk_version
}
return performAuthRequest(data, "")
end
def performOAuth(email, master_token, android_id, service, app, client_sig, device_country = 'us', operatorCountry = 'us', lang = 'en', sdk_version = 17)
data = {
'accountType': 'HOSTED_OR_GOOGLE',
'Email': email,
'has_permission': 1,
'EncryptedPasswd': master_token,
'service': service,
'source': 'android',
'androidId': android_id,
'app': app,
'client_sig': client_sig,
'device_country': device_country,
'operatorCountry': device_country,
'lang': lang,
'sdk_version': sdk_version
}
return performAuthRequest(data)
end
end
end
end