Class: PinAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/robin/pin_authenticator.rb

Class Method Summary collapse

Class Method Details

.authenticate(pin) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/robin/pin_authenticator.rb', line 21

def self.authenticate(pin)
  begin
    access_token = @request_token.get_access_token(:oauth_verifier => pin)
    Robin::User.register_new(access_token.token,
                      access_token.secret)
    true
  rescue OAuth::Unauthorized => e
    false
  end
end

.authorize_urlObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/robin/pin_authenticator.rb', line 6

def self.authorize_url
  consumer = OAuth::Consumer.new(Robin::Config.key, 
                                 Robin::Config.secret,
                                 { :site => 'http://twitter.com/',                
                                   :request_token_path => '/oauth/request_token', 
                                   :access_token_path => '/oauth/access_token',   
                                   :authorize_path => '/oauth/authorize' })
  begin
    @request_token = consumer.get_request_token 
  rescue Net::HTTPRetriableError => e
    @request_token = consumer.get_request_token 
  end
  @request_token.authorize_url()
end