Commits

Richo Healey committed 93d7b46

Catch incorrect authentication and warn the user

  • Participants
  • Parent commits d4a868c

Comments (0)

Files changed (2)

 module Twat
   VERSION_MAJOR = 0
   VERSION_MINOR = 2
-  VERSION_PATCH = 1
+  VERSION_PATCH = 2
 
   VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
   class Twat

File lib/twat/actions.rb

       token_request = oauth.get_request_token()
       puts "Please authenticate the application at #{token_request.authorize_url}, then enter pin"
       pin = gets.chomp
-      access_token = token_request.get_access_token(oauth_verifier: pin)
-      cf[opts[:account]] = {
-        oauth_token: access_token.token,
-        oauth_token_secret: access_token.secret
-      }
-      cf.save!
+      begin
+        access_token = token_request.get_access_token(oauth_verifier: pin)
+        cf[opts[:account]] = {
+          oauth_token: access_token.token,
+          oauth_token_secret: access_token.secret
+        }
+        cf.save! 
+      rescue OAuth::Unauthorized
+        puts "Couldn't authenticate you, did you enter the pin correctly?"
+      end
     end
 
     def delete(opts)