Class: OmniAuth::Strategies::Twitter

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/j1_app/omniauth/strategies/twitter.rb

Constant Summary collapse

DEFAULT_SCOPE =

OAuth client settings

'user'

Instance Method Summary collapse

Instance Method Details

#callback_pathObject



113
114
115
116
117
118
119
120
121
# File 'lib/j1_app/omniauth/strategies/twitter.rb', line 113

def callback_path
  params = session['omniauth.params']

  if params.nil? || params['callback_url'].nil?
    super
  else
    URI(params['callback_url']).path
  end
end

#callback_urlObject



105
106
107
108
109
110
111
# File 'lib/j1_app/omniauth/strategies/twitter.rb', line 105

def callback_url
  if request.params['callback_url']
    request.params['callback_url']
  else
    old_callback_url
  end
end

#old_callback_urlObject



103
# File 'lib/j1_app/omniauth/strategies/twitter.rb', line 103

alias :old_callback_url :callback_url

#old_request_phaseObject



79
# File 'lib/j1_app/omniauth/strategies/twitter.rb', line 79

alias :old_request_phase :request_phase

#raw_infoObject



73
74
75
76
77
# File 'lib/j1_app/omniauth/strategies/twitter.rb', line 73

def raw_info
  @raw_info ||= JSON.load(access_token.get('/1.1/account/verify_credentials.json?include_entities=false&skip_status=true&include_email=true').body)
rescue ::Errno::ETIMEDOUT
  raise ::Timeout::Error
end

#request_phaseObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/j1_app/omniauth/strategies/twitter.rb', line 81

def request_phase
  %w[force_login lang screen_name].each do |v|
    if request.params[v]
      options[:authorize_params][v.to_sym] = request.params[v]
    end
  end

  %w[x_auth_access_type].each do |v|
    if request.params[v]
      options[:request_params][v.to_sym] = request.params[v]
    end
  end

  if options[:use_authorize] || request.params['use_authorize'] == 'true'
    options[:client_options][:authorize_path] = '/oauth/authorize'
  else
    options[:client_options][:authorize_path] = '/oauth/authenticate'
  end

  old_request_phase
end