Object
Authentication strategy for connecting with APIs constructed using the [OAuth 2.0 Specification](tools.ietf.org/html/draft-ietf-oauth-v2-10). You must generally register your application with the provider and utilize an application id and secret in order to authenticate using OAuth 2.0.
# File lib/omniauth/strategies/oauth2.rb, line 68 def callback_phase # rubocop:disable CyclomaticComplexity error = request.params['error_reason'] || request.params['error'] if error fail!(error, CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri'])) elsif !options.provider_ignores_state && (request.params['state'].to_s.empty? || request.params['state'] != session.delete('omniauth.state')) fail!(:csrf_detected, CallbackError.new(:csrf_detected, 'CSRF detected')) else self.access_token = build_access_token self.access_token = access_token.refresh! if access_token.expired? super end rescue ::OAuth2::Error, CallbackError => e fail!(:invalid_credentials, e) rescue ::MultiJson::DecodeError => e fail!(:invalid_response, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT, Faraday::Error::TimeoutError => e fail!(:timeout, e) rescue ::SocketError, Faraday::Error::ConnectionFailed => e fail!(:failed_to_connect, e) end
# File lib/omniauth/strategies/oauth2.rb, line 37 def callback_url full_host + script_name + callback_path end
# File lib/omniauth/strategies/oauth2.rb, line 33 def client ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options)) end
# File lib/omniauth/strategies/oauth2.rb, line 91 def build_access_token verifier = request.params['code'] client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(options.auth_token_params)) end
Generated with the Darkfish Rdoc Generator 2.