class BooticClient::Strategies::Oauth2Strategy
Public Instance Methods
inspect()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 11 def inspect %(#<#{self.class.name} cid: #{config.client_id} root: #{config.api_root} auth: #{config.auth_host}>) end
Private Instance Methods
auth()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 52 def auth @auth ||= OAuth2::Client.new( config.client_id, config.client_secret, site: config.auth_host ) end
get_token()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 48 def get_token raise "Implement this in subclasses" end
pre_flight()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 23 def pre_flight update_token! unless options[:access_token] end
request_headers()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 27 def request_headers { 'Authorization' => "Bearer #{options[:access_token]}" } end
retryable() { || ... }
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 33 def retryable(&block) begin yield rescue AuthorizationError => e update_token! yield end end
update_token!()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 42 def update_token! new_token = get_token options[:access_token] = new_token on_new_token.call new_token end
validate!()
click to toggle source
# File lib/bootic_client/strategies/oauth2_strategy.rb, line 17 def validate! raise ArgumentError, 'MUST include client_id' unless config.client_id raise ArgumentError, 'MUST include client_secret' unless config.client_secret raise ArgumentError, 'MUST include api_root' unless config.api_root end