From 4671bcf71aac18670fe371febb3b8dddc74a9539 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 8 Jul 2018 08:57:06 -0500 Subject: [PATCH] Add support for Google Authenticator codes --- src/invidious.cr | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 22c91865..f03c3e87 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -524,7 +524,14 @@ post "/login" do |env| tl = challenge_results[1][2] - tfa_req = %(["#{user_hash}",null,2,null,[9,null,null,null,null,null,null,null,[null,"#{tfa_code}",false,2]]]) + request_type = tfa[8] + if request_type == 6 + # Google Authenticator code + tfa_req = %(["#{user_hash}",null,2,null,[6,null,null,null,null,["#{tfa_code}",false]]]) + else + # SMS + tfa_req = %(["#{user_hash}",null,2,null,[9,null,null,null,null,null,null,null,[null,"#{tfa_code}",false,2]]]) + end challenge_results = client.post("/_/signin/challenge?hl=en&TL=#{tl}", headers, login_req(inputs, tfa_req)) headers = challenge_results.cookies.add_request_headers(headers)