Module: TwitterAuth
- Defined in:
- lib/twitter_auth.rb,
lib/twitter_auth/cryptify.rb,
lib/twitter_auth/dispatcher/basic.rb,
lib/twitter_auth/dispatcher/oauth.rb,
app/models/twitter_auth/basic_user.rb,
app/models/twitter_auth/oauth_user.rb,
lib/twitter_auth/dispatcher/shared.rb,
app/models/twitter_auth/generic_user.rb,
lib/twitter_auth/controller_extensions.rb
Defined Under Namespace
Modules: BasicUser, ControllerExtensions, Cryptify, Dispatcher, OauthUser
Classes: Error, GenericUser
Class Method Summary
collapse
Class Method Details
.api_timeout ⇒ Object
13
14
15
|
# File 'lib/twitter_auth.rb', line 13
def self.api_timeout
config['api_timeout'] || 10
end
|
.base_url ⇒ Object
9
10
11
|
# File 'lib/twitter_auth.rb', line 9
def self.base_url
config['base_url'] || 'https://twitter.com'
end
|
.basic? ⇒ Boolean
49
50
51
|
# File 'lib/twitter_auth.rb', line 49
def self.basic?
strategy == :basic
end
|
.config(environment = RAILS_ENV) ⇒ Object
4
5
6
7
|
# File 'lib/twitter_auth.rb', line 4
def self.config(environment=RAILS_ENV)
@config ||= {}
@config[environment] ||= YAML.load(File.open(RAILS_ROOT + '/config/twitter_auth.yml').read)[environment]
end
|
.consumer ⇒ Object
The OAuth consumer used by TwitterAuth for authentication. The consumer key and secret are set in your application’s config/twitter.yml
54
55
56
57
58
59
60
|
# File 'lib/twitter_auth.rb', line 54
def self.consumer
OAuth::Consumer.new(
config['oauth_consumer_key'],
config['oauth_consumer_secret'],
:site => TwitterAuth.base_url
)
end
|
.encryption_key ⇒ Object
17
18
19
20
|
# File 'lib/twitter_auth.rb', line 17
def self.encryption_key
raise TwitterAuth::Cryptify::Error, 'You must specify an encryption_key in config/twitter_auth.yml' if config['encryption_key'].blank?
config['encryption_key']
end
|
.net ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/twitter_auth.rb', line 62
def self.net
uri = URI.parse(TwitterAuth.base_url)
net = Net::HTTP.new(uri.host, uri.port)
net.use_ssl = uri.scheme == 'https'
net.read_timeout = TwitterAuth.api_timeout
net
end
|
.oauth? ⇒ Boolean
45
46
47
|
# File 'lib/twitter_auth.rb', line 45
def self.oauth?
strategy == :oauth
end
|
.oauth_callback ⇒ Object
26
27
28
|
# File 'lib/twitter_auth.rb', line 26
def self.oauth_callback
config['oauth_callback']
end
|
.oauth_callback? ⇒ Boolean
22
23
24
|
# File 'lib/twitter_auth.rb', line 22
def self.oauth_callback?
config.key?('oauth_callback')
end
|
.remember_for ⇒ Object
30
31
32
|
# File 'lib/twitter_auth.rb', line 30
def self.remember_for
(config['remember_for'] || 14).to_i
end
|
.strategy ⇒ Object
The authentication strategy employed by this application. Set in config/twitter.yml
as strategy; valid options are oauth or basic.
37
38
39
40
41
42
43
|
# File 'lib/twitter_auth.rb', line 37
def self.strategy
strat = config['strategy']
raise ArgumentError, 'Invalid TwitterAuth Strategy: Valid strategies are oauth and basic.' unless %w(oauth basic).include?(strat)
strat.to_sym
rescue Errno::ENOENT
:oauth
end
|