Sha256: 92520161053f066fb94c26370fcdff32cf8c8e8b1cec545d4cecdc0a8597c348

Contents?: true

Size: 1.99 KB

Versions: 115

Compression:

Stored size: 1.99 KB

Contents

require "colored"
require "credentials_manager"
require 'yaml'

module Spaceship
  class SpaceauthRunner
    def initialize(username: nil)
      @username = username
      @username ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
      @username ||= ask("Username: ")
    end

    def run
      begin
        puts "Logging into to iTunes Connect (#{@username})..."
        Spaceship::Tunes.login(@username)
        puts "Successfully logged in to iTunes Connect".green
        puts ""
      rescue
        puts "Could not login to iTunes Connect".red
        puts "Please check your credentials and try again.".yellow
        puts "This could be an issue with iTunes Connect,".yellow
        puts "Please try unsetting the FASTLANE_SESSION environment variable".yellow
        puts "and re-run `fastlane spaceauth`".yellow
        UI.crash!("Problem connecting to iTunes Connect")
      end

      itc_cookie_content = Spaceship::Tunes.client.store_cookie

      # The only value we actually need is the "DES5c148586daa451e55afb017aa62418f91" cookie
      # We're not sure if the key changes
      #
      # Example:
      # name: DES5c148586daa451e55afb017aa62418f91
      # value: HSARMTKNSRVTWFlaF/ek8asaa9lymMA0dN8JQ6pY7B3F5kdqTxJvMT19EVEFX8EQudB/uNwBHOHzaa30KYTU/eCP/UF7vGTgxs6PAnlVWKscWssOVHfP2IKWUPaa4Dn+I6ilA7eAFQsiaaVT
      cookies = YAML.safe_load(
        itc_cookie_content,
        [HTTP::Cookie, Time], # classes whitelist
        [],                   # symbols whitelist
        true                  # allow YAML aliases
      )

      # We remove all the un-needed cookies
      cookies.select! do |cookie|
        cookie.name.start_with?("DES5") || cookie.name == 'dqsid'
      end

      yaml = cookies.to_yaml.gsub("\n", "\\n")

      puts "---"
      puts ""
      puts "Pass the following via the FASTLANE_SESSION environment variable:"
      puts yaml.cyan.underline
      puts ""
      puts ""
      puts "Example:"
      puts "export FASTLANE_SESSION='#{yaml}'".cyan.underline
    end
  end
end

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
fastlane-2.29.0.beta.20170505010029 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170504010033 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.28.8 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170503010035 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170502010055 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170501010050 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170430010051 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.28.7 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170429010036 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.28.6 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170428010037 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170427010043 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.28.5 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170426010043 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.28.4 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170425010038 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170424010049 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170423010015 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.29.0.beta.20170422010059 spaceship/lib/spaceship/spaceauth_runner.rb
fastlane-2.28.3 spaceship/lib/spaceship/spaceauth_runner.rb