32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/evernote-utils.rb', line 32
def self.interactiveGetToken
callback_url = "http://zzamboni.org/enwrite-callback.html"
client = EvernoteOAuth::Client.new(token: nil, consumer_key: OAUTH_CONSUMER_KEY, consumer_secret: OAUTH_CONSUMER_SECRET, sandbox: SANDBOX)
request_token = client.request_token(:oauth_callback => callback_url)
authorize_url = request_token.authorize_url
puts("Welcome to enwrite's Evernote authentication.
Please open the following URL:
#{authorize_url}
Once you authenticate you will be redirected to
a page in the zzamboni.org domain that will show you an authentication verifier
token. Please enter that token now.")
print("> ")
$stdout.flush
oauth_verifier = gets.chomp
access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
puts("Thank you! Your access token is the following string:
#{access_token.token}
I can store the token for you in the config file (#{config_file}),
then enwrite will use it automatically in the future.
")
print "Would you like me to do that for you now (Y/n)? "
$stdout.flush
yesno = gets.chomp
if yesno =~ /^([yY].*|)$/
setconfig(:evernote_auth_token, access_token.token)
puts "Token stored."
else
puts "OK, I won't store the token, just use it for now.
You can also store it in the ENWRITE_AUTH_TOKEN environment variable."
end
@@forceAuth = false
return access_token.token
end
|