Class: CalendarAssistant::CLI::Authorizer
- Inherits:
-
Object
- Object
- CalendarAssistant::CLI::Authorizer
- Defined in:
- lib/calendar_assistant/cli/authorizer.rb
Defined Under Namespace
Classes: NoCredentials, UnauthorizedError
Constant Summary collapse
- OOB_URI =
"urn:ietf:wg:oauth:2.0:oob".freeze
- APPLICATION_NAME =
"Flavorjones Calendar Assistant".freeze
- CREDENTIALS_PATH =
File.join (ENV["CA_HOME"] || ENV["HOME"]), ".calendar-assistant.client"
- SCOPE =
Google::Apis::CalendarV3::AUTH_CALENDAR
Instance Attribute Summary collapse
-
#config_token_store ⇒ Object
readonly
Returns the value of attribute config_token_store.
-
#profile_name ⇒ Object
readonly
Returns the value of attribute profile_name.
Instance Method Summary collapse
- #authorize ⇒ Object
-
#initialize(profile_name, config_token_store) ⇒ Authorizer
constructor
A new instance of Authorizer.
- #service ⇒ Object
Constructor Details
#initialize(profile_name, config_token_store) ⇒ Authorizer
Returns a new instance of Authorizer.
33 34 35 36 |
# File 'lib/calendar_assistant/cli/authorizer.rb', line 33 def initialize(profile_name, config_token_store) @profile_name = profile_name @config_token_store = config_token_store end |
Instance Attribute Details
#config_token_store ⇒ Object (readonly)
Returns the value of attribute config_token_store.
31 32 33 |
# File 'lib/calendar_assistant/cli/authorizer.rb', line 31 def config_token_store @config_token_store end |
#profile_name ⇒ Object (readonly)
Returns the value of attribute profile_name.
31 32 33 |
# File 'lib/calendar_assistant/cli/authorizer.rb', line 31 def profile_name @profile_name end |
Instance Method Details
#authorize ⇒ Object
38 39 40 |
# File 'lib/calendar_assistant/cli/authorizer.rb', line 38 def credentials || end |
#service ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/calendar_assistant/cli/authorizer.rb', line 42 def service if credentials.nil? raise UnauthorizedError, "Not authorized. Please run `calendar-assistant authorize #{profile_name}`" end Google::Apis::CalendarV3::CalendarService.new.tap do |service| service..application_name = APPLICATION_NAME service. = credentials end end |