class OmniAuth::Strategies::GoogleChromeIdentity
Public Instance Methods
callback_phase()
click to toggle source
# File lib/omniauth/strategies/google_chrome_identity.rb, line 44 def callback_phase if !request.params['access_token'] || request.params['access_token'].to_s.empty? raise ArgumentError.new("No access token provided.") end self.access_token = build_access_token self.access_token = self.access_token.refresh! if self.access_token.expired? self.env['omniauth.auth'] = auth_hash call_app! rescue ::OAuth2::Error => e fail!(:invalid_credentials, e) rescue ::MultiJson::DecodeError => e fail!(:invalid_response, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e fail!(:timeout, e) rescue ::SocketError => e fail!(:failed_to_connect, e) end
request_phase()
click to toggle source
# File lib/omniauth/strategies/google_chrome_identity.rb, line 40 def request_phase fail "Nope" end
Protected Instance Methods
build_access_token()
click to toggle source
# File lib/omniauth/strategies/google_chrome_identity.rb, line 68 def build_access_token ::OAuth2::AccessToken.from_hash(client, { access_token: request.params['access_token'], header_format: 'OAuth %s', param_name: 'access_token' }) end
Private Instance Methods
image_url(options)
click to toggle source
# File lib/omniauth/strategies/google_chrome_identity.rb, line 78 def image_url(options) original_url = raw_info['picture'] return original_url if original_url.nil? || (!options[:image_size] && !options[:image_aspect_ratio]) image_params = [] if options[:image_size].is_a?(Integer) image_params << "s#{options[:image_size]}" elsif options[:image_size].is_a?(Hash) image_params << "w#{options[:image_size][:width]}" if options[:image_size][:width] image_params << "h#{options[:image_size][:height]}" if options[:image_size][:height] end image_params << 'c' if options[:image_aspect_ratio] == 'square' params_index = original_url.index('/photo.jpg') original_url.insert(params_index, ('/' + image_params.join('-'))) end
prune!(hash)
click to toggle source
# File lib/omniauth/strategies/google_chrome_identity.rb, line 95 def prune!(hash) hash.delete_if do |_, v| prune!(v) if v.is_a?(Hash) v.nil? || (v.respond_to?(:empty?) && v.empty?) end end
raw_info()
click to toggle source
# File lib/omniauth/strategies/google_chrome_identity.rb, line 102 def raw_info @raw_info ||= access_token.get('https://www.googleapis.com/oauth2/v2/userinfo').parsed end