tkohout / fastlane-firebase-plugin

Unofficial tool to access firebase project settings
MIT License
35 stars 24 forks source link

two-factor authorization #4

Closed davidseca closed 7 years ago

davidseca commented 7 years ago

I have two-factor authorization on my Google Account.

When i run the lane it asks me for the password and then there is an error because it waits for the 6-digit code.

There is the option of creating an App password on my Google Account but of course it does not work with web-based login.

Is there a way to use two-factor authorization with fastlane-plugin-firebase?

Here is my lane:

lane :firebasePoC do
  firebase_add_client(
    username: firebaseUser,
    project_number: pocFirebaseProjectNumber,
    download_config: true,
    type: "ios",
    bundle_id: pocBundleId,
    output_path: "./PoC/"
  )

  firebase_upload_certificate(
    username: firebaseUser,
    p12_path: pocP12Path,
    p12_password: pocP12Password,
    project_number: pocFirebaseProjectNumber,
    client_id: "ios:#{pocBundleId}",
    type: "production"
  )
end

Here is the terminal output:

DEBUG [2017-08-08 11:09:48.96]: Checking if there are any plugins that should be loaded...
DEBUG [2017-08-08 11:09:48.96]: Loading 'fastlane-plugin-latest_hockeyapp_version_number' plugin
INFO [2017-08-08 11:09:49.01]: gem 'fastlane-plugin-latest_hockeyapp_version_number' is already installed
DEBUG [2017-08-08 11:09:49.02]: Loading 'fastlane-plugin-firebase' plugin
INFO [2017-08-08 11:09:49.07]: gem 'fastlane-plugin-firebase' is already installed
+-------------------------------------------------+---------+------------------------------------------------------------------------------------+
|                                                                  Used plugins                                                                  |
+-------------------------------------------------+---------+------------------------------------------------------------------------------------+
| Plugin                                          | Version | Action                                                                             |
+-------------------------------------------------+---------+------------------------------------------------------------------------------------+
| fastlane-plugin-latest_hockeyapp_version_number | 1.0.0   | latest_hockeyapp_version_number                                                    |
| fastlane-plugin-firebase                        | 0.2.0   | firebase_add_client firebase_delete_client firebase_download_config firebase_list  |
|                                                 |         | firebase_upload_certificate                                                        |
+-------------------------------------------------+---------+------------------------------------------------------------------------------------+

INFO [2017-08-08 11:09:49.46]: -----------------------------
INFO [2017-08-08 11:09:49.46]: --- Step: update_fastlane ---
INFO [2017-08-08 11:09:49.46]: -----------------------------
INFO [2017-08-08 11:09:49.46]: Looking for updates for fastlane...
INFO [2017-08-08 11:09:52.76]: Nothing to update ✅
INFO [2017-08-08 11:09:52.76]: 
INFO [2017-08-08 11:09:52.76]: Please help us test early releases of fastlane by opting into nightly builds 🌃
INFO [2017-08-08 11:09:52.76]: Just replace your `update_fastlane` call with
INFO [2017-08-08 11:09:52.76]: 
INFO [2017-08-08 11:09:52.76]: ▸ update_fastlane(nightly: true)
INFO [2017-08-08 11:09:52.76]: 
INFO [2017-08-08 11:09:52.76]: Nightly builds are reviewed and tested just like the public releases 🚂
INFO [2017-08-08 11:09:52.76]: 
INFO [2017-08-08 11:09:52.77]: -------------------------------------------------
INFO [2017-08-08 11:09:52.77]: --- Step: Verifying required fastlane version ---
INFO [2017-08-08 11:09:52.77]: -------------------------------------------------
INFO [2017-08-08 11:09:52.77]: Your fastlane version 2.51.0 matches the minimum requirement of 2.46.0  ✅
INFO [2017-08-08 11:09:52.77]: ------------------------------
INFO [2017-08-08 11:09:52.77]: --- Step: default_platform ---
INFO [2017-08-08 11:09:52.77]: ------------------------------
INFO [2017-08-08 11:09:52.77]: Driving the lane 'ios firebasePoC' 🚀
INFO [2017-08-08 11:09:52.77]: ---------------------------------
INFO [2017-08-08 11:09:52.77]: --- Step: firebase_add_client ---
INFO [2017-08-08 11:09:52.77]: ---------------------------------
 [2017-08-08 11:09:52.82]: Password for ******@gmail.com
******************
INFO [2017-08-08 11:09:59.92]: Logging in to Google account ******@gmail.com
INFO [2017-08-08 11:10:00.48]: -------------------------
INFO [2017-08-08 11:10:00.48]: --- Sign-in challenge ---
INFO [2017-08-08 11:10:00.48]: -------------------------
INFO [2017-08-08 11:10:01.35]: ---------------------
INFO [2017-08-08 11:10:01.35]: --- Step: hipchat ---
INFO [2017-08-08 11:10:01.35]: ---------------------
DEBUG [2017-08-08 11:10:01.35]: Taking value for 'api_token' from environment variable 'HIPCHAT_API_TOKEN'
DEBUG [2017-08-08 11:10:01.36]: Taking value for 'version' from environment variable 'HIPCHAT_API_VERSION'
DEBUG [2017-08-08 11:10:01.36]: Taking value for 'api_host' from environment variable 'HIPCHAT_API_HOST'
DEBUG [2017-08-08 11:10:01.36]: Taking value for 'channel' from environment variable 'FL_HIPCHAT_CHANNEL'
WARN [2017-08-08 11:10:01.55]: Lane Context:
INFO [2017-08-08 11:10:01.55]: {:DEFAULT_PLATFORM=>:ios, :PLATFORM_NAME=>:ios, :LANE_NAME=>"ios firebasePoC"}
ERROR [2017-08-08 11:10:01.55]: Unknown challenge type 

<form method="POST" id="challenge" action="/signin/challenge/totp/2" jsname="rzWj5" jscontroller="HNBfvc" jsaction="submit:zbvklb" jsshadow><content><input name="challengeId" type="hidden" id="challengeId" value="2"><input name="challengeType" type="hidden" id="challengeType" value="6"><input name="continue" type="hidden" value="https://console.firebase.google.com/"><input name="osid" type="hidden" value="1"><input name="TL" type="hidden" value="A****"><input type="hidden" name="gxf" id="gxf" value="A****"><div jsname="KrwUDc">
<img jsname="TqVmm" class="JC07Dd" src="//ssl.gstatic.com/accounts/marc/authenticator.png" alt=""><div class="EGmPD" jsname="BCqkPb">Enter a verification code</div>
<div class="VnJmLc" jsname="NhJ5Dd">Get a verification code from the <strong>Google Authenticator</strong> app</div>
<div class="gIH97b"><input type="tel" pattern="[0-9 ]*" id="totpPin" name="Pin" dir="ltr" autocomplete="off" placeholder="Enter the 6-digit code" autofocus class="y1x0pc"></div>
<input type="submit" class="MK9CEd MVpUfe" jsname="M2UYVd" jscontroller="rrJN5c" jsaction="aJAbCd:zbvklb" value="Done" id="submit"><div class="ARshqb">
<input type="checkbox" name="TrustDevice" id="trustDevice" class="aCOJmf" checked><span>Don't ask again on this computer</span><div class="Bfmfyc" role="tooltip">
<div class="x7qQqf"></div>
<div class="hzC8Lb">For your convenience, keep this ticked. On shared devices, additional precautions are recommended. <a href="https://support.google.com/accounts/?p=securesignin&amp;hl=en_GB" target="_blank">Learn more</a>
</div>
</div>
</div>
</div></content></form>
INFO [2017-08-08 11:10:01.56]: Successfully generated documentation at path '/*****/fastlane/README.md'

+------+-------------------------------------+-------------+
|                     fastlane summary                     |
+------+-------------------------------------+-------------+
| Step | Action                              | Time (in s) |
+------+-------------------------------------+-------------+
| 1    | update_fastlane                     | 3           |
| 2    | Verifying required fastlane version | 0           |
| 3    | default_platform                    | 0           |
| 💥   | firebase_add_client                 | 7           |
| 5    | hipchat                             | 0           |
+------+-------------------------------------+-------------+

DEBUG [2017-08-08 11:10:01.57]: All plugins are up to date
ERROR [2017-08-08 11:10:01.57]: fastlane finished with errors
DEBUG [2017-08-08 11:10:01.58]: All plugins are up to date
bundler: failed to load command: fastlane (/usr/local/bin/fastlane)
FastlaneCore::Interface::FastlaneError: [!] Unknown challenge type 

<form method="POST" id="challenge" action="/signin/challenge/totp/2" jsname="rzWj5" jscontroller="HNBfvc" jsaction="submit:zbvklb" jsshadow><content><input name="challengeId" type="hidden" id="challengeId" value="2"><input name="challengeType" type="hidden" id="challengeType" value="6"><input name="continue" type="hidden" value="https://console.firebase.google.com/"><input name="osid" type="hidden" value="1"><input name="TL" type="hidden" value="AHnYQLy-*****"><input type="hidden" name="gxf" id="gxf" value="A****"><div jsname="KrwUDc">
<img jsname="TqVmm" class="JC07Dd" src="//ssl.gstatic.com/accounts/marc/authenticator.png" alt=""><div class="EGmPD" jsname="BCqkPb">Enter a verification code</div>
<div class="VnJmLc" jsname="NhJ5Dd">Get a verification code from the <strong>Google Authenticator</strong> app</div>
<div class="gIH97b"><input type="tel" pattern="[0-9 ]*" id="totpPin" name="Pin" dir="ltr" autocomplete="off" placeholder="Enter the 6-digit code" autofocus class="y1x0pc"></div>
<input type="submit" class="MK9CEd MVpUfe" jsname="M2UYVd" jscontroller="rrJN5c" jsaction="aJAbCd:zbvklb" value="Done" id="submit"><div class="ARshqb">
<input type="checkbox" name="TrustDevice" id="trustDevice" class="aCOJmf" checked><span>Don't ask again on this computer</span><div class="Bfmfyc" role="tooltip">
<div class="x7qQqf"></div>
<div class="hzC8Lb">For your convenience, keep this ticked. On shared devices, additional precautions are recommended. <a href="https://support.google.com/accounts/?p=securesignin&amp;hl=en_GB" target="_blank">Learn more</a>
</div>
</div>
</div>
</div></content></form>
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane_core/lib/fastlane_core/ui/interface.rb:131:in `user_error!'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane_core/lib/fastlane_core/ui/ui.rb:14:in `method_missing'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-plugin-firebase-0.2.0/lib/fastlane/plugin/firebase/lib/api.rb:144:in `signin_challenge'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-plugin-firebase-0.2.0/lib/fastlane/plugin/firebase/lib/api.rb:61:in `login'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-plugin-firebase-0.2.0/lib/fastlane/plugin/firebase/lib/api.rb:27:in `initialize'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-plugin-firebase-0.2.0/lib/fastlane/plugin/firebase/lib/manager.rb:19:in `new'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-plugin-firebase-0.2.0/lib/fastlane/plugin/firebase/lib/manager.rb:19:in `login'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-plugin-firebase-0.2.0/lib/fastlane/plugin/firebase/actions/firebase_add_client_action.rb:8:in `run'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:252:in `block (2 levels) in execute_action'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/actions/actions_helper.rb:50:in `execute_action'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:230:in `block in execute_action'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:226:in `chdir'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:226:in `execute_action'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:148:in `trigger_action_by_name'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/fast_file.rb:146:in `method_missing'
  Fastfile:196:in `block (2 levels) in parsing_binding'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/lane.rb:33:in `call'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/lane_manager.rb:52:in `cruise_lane'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/command_line_handler.rb:30:in `handle'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/commands_generator.rb:104:in `block (2 levels) in run'
  /usr/local/lib/ruby/gems/2.4.0/gems/commander-fastlane-4.4.5/lib/commander/command.rb:178:in `call'
  /usr/local/lib/ruby/gems/2.4.0/gems/commander-fastlane-4.4.5/lib/commander/command.rb:153:in `run'
  /usr/local/lib/ruby/gems/2.4.0/gems/commander-fastlane-4.4.5/lib/commander/runner.rb:476:in `run_active_command'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:64:in `run!'
  /usr/local/lib/ruby/gems/2.4.0/gems/commander-fastlane-4.4.5/lib/commander/delegates.rb:15:in `run!'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/commands_generator.rb:303:in `run'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/commands_generator.rb:42:in `start'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/fastlane/lib/fastlane/cli_tools_distributor.rb:66:in `take_off'
  /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.51.0/bin/fastlane:20:in `<top (required)>'
  /usr/local/bin/fastlane:22:in `load'
  /usr/local/bin/fastlane:22:in `<top (required)>'
tkohout commented 7 years ago

Hello @davidseca , thanks for submitting the issue. There actually is a way to use the plugin with SMS based two step verification. I added the Google Authenticator in the latest release. Let me know whether it works for you.

davidseca commented 7 years ago

Hello @tkohout ,

Thanks for your quick answer. I have tried the both approaches (sms and Google-Authenticator-App). And both of them work for me. I have seen that Google-Authenticator-App method and sms method are exclusive between then; I mean, once a Google-Authenticator-App is configured, it is not asked for sms method. I think because it is in Google web login.

But of course in both cases (sms and Google-Authenticator-App) an user interaction is needed.

So currently using a two-factor Auth cannot be a complete automatic process, isn't it?

tkohout commented 7 years ago

Yes, well there is a mechanism of Trusted device but I am not sure what google uses to identify a device. I might look into it in future but for now the only option for complete automatic process is to use an account with the two-step verification turned off.

EDIT: The method used for the authetication is always the default one

davidseca commented 7 years ago

Hello @tkohout ,

Yes, a complete automatic process using a two-factor Auth would be a useful feature in future.

Thanks so much you answer all my questions.