Update Google login

pull/633/head
Omar Roth 6 years ago
parent af592ea8c1
commit 1a7b341745
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2

@ -922,20 +922,18 @@ post "/login" do |env|
begin begin
client = make_client(LOGIN_URL) client = make_client(LOGIN_URL)
headers = HTTP::Headers.new headers = HTTP::Headers.new
headers["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8"
headers["Google-Accounts-XSRF"] = "1"
headers["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36"
headers["X-Same-Domain"] = "1"
login_page = client.get("/ServiceLogin?flowName=GlifWebSignIn&flowEntry=ServiceLogin&cid=1&navigationDirection=forward") login_page = client.get("/ServiceLogin")
headers = login_page.cookies.add_request_headers(headers) headers = login_page.cookies.add_request_headers(headers)
lookup_req = { lookup_req = {
email, nil, [] of String, nil, "US", nil, nil, 2, false, true, email, nil, [] of String, nil, "US", nil, nil, 2, false, true,
{nil, nil, {nil, nil,
{2, 1, nil, 1, "https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn", nil, [] of String, 4, [] of String, "GlifWebSignIn"}, {2, 1, nil, 1,
"https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn",
nil, [] of String, 4},
1, 1,
{nil, nil, [] of String, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [] of String, nil, nil, nil, [] of String, [] of String}, {nil, nil, [] of String},
nil, nil, nil, true, nil, nil, nil, true,
}, },
email, email,
@ -943,8 +941,10 @@ post "/login" do |env|
traceback << "Getting lookup..." traceback << "Getting lookup..."
headers["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8"
headers["Google-Accounts-XSRF"] = "1"
response = client.post("/_/signin/sl/lookup", headers, login_req(lookup_req)) response = client.post("/_/signin/sl/lookup", headers, login_req(lookup_req))
headers = response.cookies.add_request_headers(headers)
lookup_results = JSON.parse(response.body[5..-1]) lookup_results = JSON.parse(response.body[5..-1])
traceback << "done, returned #{response.status_code}.<br/>" traceback << "done, returned #{response.status_code}.<br/>"
@ -957,9 +957,11 @@ post "/login" do |env|
{password, nil, true}, {password, nil, true},
}, },
{nil, nil, {nil, nil,
{2, 1, nil, 1, "https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn", nil, [] of String, 4, [] of String, "GlifWebSignIn"}, {2, 1, nil, 1,
"https://accounts.google.com/ServiceLogin?passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Fnext%3D%252F%26action_handle_signin%3Dtrue%26hl%3Den%26app%3Ddesktop%26feature%3Dsign_in_button&hl=en&service=youtube&uilel=3&requestPath=%2FServiceLogin&Page=PasswordSeparationSignIn",
nil, [] of String, 4},
1, 1,
{nil, nil, [] of String, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, [] of String, nil, nil, nil, [] of String, [] of String}, {nil, nil, [] of String},
nil, nil, nil, true, nil, nil, nil, true,
}, },
}.to_json }.to_json

@ -176,25 +176,24 @@ end
def login_req(f_req) def login_req(f_req)
data = { data = {
# "azt" => "",
# "bgHash" => "",
# Unfortunately there's not much information available on `bgRequest`; part of Google's BotGuard # Unfortunately there's not much information available on `bgRequest`; part of Google's BotGuard
# Generally this is much longer (>1250 characters), similar to Amazon's `metaData1` # Generally this is much longer (>1250 characters), see also
# (see https://github.com/omarroth/audible.cr/blob/master/src/audible/crypto.cr#L43). # https://github.com/ytdl-org/youtube-dl/commit/baf67a604d912722b0fe03a40e9dc5349a2208cb .
# For now this can be empty. # For now this can be empty.
"bgRequest" => %|["identifier","!AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"]|, "bgRequest" => %|["identifier",""]|,
"pstMsg" => "1",
"checkConnection" => "youtube",
"checkedDomains" => "youtube",
"hl" => "en",
"deviceinfo" => %|[null,null,null,[],null,"US",null,null,[],"GlifWebSignIn",null,[null,null,[]]]|,
"f.req" => f_req,
"flowName" => "GlifWebSignIn", "flowName" => "GlifWebSignIn",
"flowEntry" => "ServiceLogin", "flowEntry" => "ServiceLogin",
"continue" => "https://accounts.google.com/ManageAccount", # "cookiesDisabled" => "false",
"f.req" => f_req, # "gmscoreversion" => "undefined",
"cookiesDisabled" => "false", # "continue" => "https://accounts.google.com/ManageAccount",
"deviceinfo" => %([null,null,null,[],null,"US",null,null,[],"GlifWebSignIn",null,[null,null,[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[],null,null,null,[],[]]]), # "azt" => "",
"gmscoreversion" => "undefined", # "bgHash" => "",
"checkConnection" => "youtube:303:1",
"checkedDomains" => "youtube",
"pstMsg" => "1",
} }
return HTTP::Params.encode(data) return HTTP::Params.encode(data)

Loading…
Cancel
Save