Class: Twurl::AuthorizationController

Inherits:
AbstractCommandController show all
Defined in:
lib/twurl/authorization_controller.rb

Constant Summary collapse

AUTHORIZATION_FAILED_MESSAGE =
"Authorization failed. Check that your consumer key and secret are correct, as well as username and password."
AUTHORIZATION_SUCCEEDED_MESSAGE =
"Authorization successful"

Instance Attribute Summary

Attributes inherited from AbstractCommandController

#client, #options

Instance Method Summary collapse

Methods inherited from AbstractCommandController

dispatch, #initialize

Constructor Details

This class inherits a constructor from Twurl::AbstractCommandController

Instance Method Details

#dispatchObject



5
6
7
8
9
10
11
# File 'lib/twurl/authorization_controller.rb', line 5

def dispatch
  client.exchange_credentials_for_access_token
  client.save
  CLI.puts AUTHORIZATION_SUCCEEDED_MESSAGE
rescue OAuth::Unauthorized
  raise Exception, AUTHORIZATION_FAILED_MESSAGE
end