3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/twterm/auth.rb', line 3
def authenticate_user(config)
consumer = OAuth::Consumer.new(
'vLNSVFgXclBJQJRZ7VLMxL9lA',
'OFLKzrepRG2p1hq0nUB9j2S9ndFQoNTPheTpmOY0GYw55jGgS5',
site: 'https://api.twitter.com'
)
request_token = consumer.get_request_token
url = request_token.authorize_url
begin
Launchy.open(url)
rescue Launchy::CommandNotFoundError
puts "Open the following URL to authorize yourself: #{url}"
end
print 'Input PIN: '
pin = (STDIN.gets || '').strip
access_token = request_token.get_access_token(oauth_verifier: pin)
config[:access_token] = access_token.token
config[:access_token_secret] = access_token.secret
config[:screen_name] = access_token.params[:screen_name]
config[:user_id] = access_token.params[:user_id].to_i
end
|