Method: Spaceship::Client#request_two_factor_code_from_phone
- Defined in:
- spaceship/lib/spaceship/two_step_or_factor_client.rb
#request_two_factor_code_from_phone(phone_id, phone_number, code_length, push_mode = "sms", should_request_code = true) ⇒ Object
this is used in two places: after choosing a phone number and when a phone number is set via ENV var
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'spaceship/lib/spaceship/two_step_or_factor_client.rb', line 325 def request_two_factor_code_from_phone(phone_id, phone_number, code_length, push_mode = "sms", should_request_code = true) if should_request_code # Request code r = request(:put) do |req| req.url("https://idmsa.apple.com/appleauth/auth/verify/phone") req.headers['Content-Type'] = 'application/json' req.body = { "phoneNumber" => { "id" => phone_id }, "mode" => push_mode }.to_json update_request_headers(req) end # we use `Spaceship::TunesClient.new.handle_itc_response` # since this might be from the Dev Portal, but for 2 step Spaceship::TunesClient.new.handle_itc_response(r.body) puts("Successfully requested text message to #{phone_number}") end code = ask_for_2fa_code("Please enter the #{code_length} digit code you received at #{phone_number}:") return { "securityCode" => { "code" => code.to_s }, "phoneNumber" => { "id" => phone_id }, "mode" => push_mode }.to_json end |