Class: Tweetwine::OAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/tweetwine/oauth.rb

Constant Summary collapse

SEP =
':'
CON =
Obfuscate.read(<<-END).split(SEP)
enpGfklDSjc7K0s+cklwdipiRiY6cGk8J0U5diFfZHh0JzxnfD5lPzxJcXN6
PitkPXNhYGh7M194Qyc2PHgrRkdn
END

Instance Method Summary collapse

Constructor Details

#initialize(access = nil) ⇒ OAuth

Returns a new instance of OAuth.



14
15
16
17
18
19
20
# File 'lib/tweetwine/oauth.rb', line 14

def initialize(access = nil)
  @access_key, @access_secret = *if access
    Obfuscate.read(access).split(SEP)
  else
    ['', '']
  end
end

Instance Method Details

#authorize {|obfuscate_access_token| ... } ⇒ Object

Yields:

  • (obfuscate_access_token)


22
23
24
25
26
27
28
29
# File 'lib/tweetwine/oauth.rb', line 22

def authorize
  request_token = get_request_token
  CLI.ui.info "Please authorize: #{request_token.authorize_url}"
  pin = CLI.ui.prompt 'Enter PIN'
  access_token = get_access_token(request_token, pin)
  reset_access_token(access_token)
  yield(obfuscate_access_token) if block_given?
end

#request_signerObject



31
32
33
34
35
# File 'lib/tweetwine/oauth.rb', line 31

def request_signer
  @signer ||= lambda do |connection, request|
    request.oauth! connection, consumer, access_token
  end
end