Class: WeConnect::Authentication::WebLogin

Inherits:
Object
  • Object
show all
Defined in:
lib/weconnect/authorization.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, car_info) ⇒ WebLogin

Returns a new instance of WebLogin.



55
56
57
58
# File 'lib/weconnect/authorization.rb', line 55

def initialize(connection,car_info)
  @connection = connection
  @car_info = car_info
end

Instance Method Details

#loginObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/weconnect/authorization.rb', line 59

def 
  @connection.format = 'x-www-form-urlencoded'
  page = 
  form = PasswordFormParser.new(page.body)
  page = email_page_step(form)
  idk = IDKParser.new(page.body)
  page = password_page_step(idk)

  raise IncompatibleAPIError.new( "#{@car_info.redirect} redirect not found" )
rescue WeconnectAuthenticated => authenticated
  # weconnect://authenticatied#... extpected

  @tokens = query_parameters(URI.parse(authenticated.redirect).fragment)
  # fetch final tokens from login
  @tokens = fetch_tokens(@tokens)
end