spaceship/lib/spaceship/tunes/tunes_client.rb
# ITunesConnectError is only thrown when iTunes Connect raises an exception
ITunesConnectError is only thrown when iTunes Connect raises an exception
ITunesConnectError is only thrown when iTunes Connect raises an exception
def send_login_request(user, password)
      clear_user_cached_data
      data = {
        accountName: user,
        password: password,
        rememberMe: true
      }
      begin
        response = request(:post) do |req|
          req.url "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=#{service_key}"
          req.body = data.to_json
          req.headers['Content-Type'] = 'application/json'
          req.headers['X-Requested-With'] = 'XMLHttpRequest'
          req.headers['Accept'] = 'application/json, text/javascript'
        end
      rescue UnauthorizedAccessError
        raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username."
      end
      request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/route?noext")
      request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa")
      case response.status
      when 403
        raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username."
      when 200
        return response
      else
        if response["Location"] == "/auth" 
          raise "spaceship / fastlane doesn't support 2 step enabled accounts yet. Please temporary disable 2 step verification until spaceship was updated."
        elsif (response.body || "").include?('invalid="true"')
          raise InvalidUserCredentialsError.new, "Invalid username and password combination. Used '#{user}' as the username."
        elsif (response['Set-Cookie'] || "").include?("itctx")
          raise "Looks like your Apple ID is not enabled for iTunes Connect, make sure to be able to login online"
        else
          info = [response.body, response['Set-Cookie']]
          raise ITunesConnectError.new, info.join("\n")
        end
      end
    end
def send_login_request ( user , password ) clear_user_cached_data data = { accountName : user , password : password , rememberMe : true } begin response = request ( :post ) do | req | req . url "https://idmsa.apple.com/appleauth/auth/signin?widgetKey=#{service_key}" req . body = data . to_json req . headers [ 'Content-Type' ] = 'application/json' req . headers [ 'X-Requested-With' ] = 'XMLHttpRequest' req . headers [ 'Accept' ] = 'application/json, text/javascript' end rescue UnauthorizedAccessError raise InvalidUserCredentialsError . new , "Invalid username and password combination. Used '#{user}' as the username." end request ( :get , "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/route?noext" ) request ( :get , "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa" ) case response . status when 403 raise InvalidUserCredentialsError . new , "Invalid username and password combination. Used '#{user}' as the username." when 200 return response else if response [ "Location" ] == "/auth" raise "spaceship / fastlane doesn't support 2 step enabled accounts yet. Please temporary disable 2 step verification until spaceship was updated." elsif ( response . body || "" ) . include? ( 'invalid="true"' ) raise InvalidUserCredentialsError . new , "Invalid username and password combination. Used '#{user}' as the username." elsif ( response [ 'Set-Cookie' ] || "" ) . include? ( "itctx" ) raise "Looks like your Apple ID is not enabled for iTunes Connect, make sure to be able to login online" else info = [ response . body , response [ 'Set-Cookie' ] ] raise ITunesConnectError . new , info . join ( "\n" ) end end end
ITunesConnectError is only thrown when iTunes Connect raises an exception
ITunesConnectError is only thrown when iTunes Connect raises an exception
# get woinst, wois, and itctx cookie values # redirect to 2 step auth page # User Credentials are wrong
user
<not_specific>
password
<not_specific>