Class: WeConnect::Authentication::WebLogin
- Inherits:
-
Object
- Object
- WeConnect::Authentication::WebLogin
- Defined in:
- lib/weconnect/authorization.rb
Instance Method Summary collapse
-
#initialize(connection, car_info) ⇒ WebLogin
constructor
A new instance of WebLogin.
- #login ⇒ Object
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
#login ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/weconnect/authorization.rb', line 59 def login @connection.format = 'x-www-form-urlencoded' page = login_page_step 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 |