added url argument to block_for_auth, fixed tests for LinkedIn
[hermes] / package / src / org / maemo / hermes / engine / linkedin / api.py
index 0d9eb24..ceb2c00 100644 (file)
@@ -43,15 +43,13 @@ class LinkedInApi():
         self.consumer = oauth.OAuthConsumer(api_key, secret_key)
         self.sig_method = oauth.OAuthSignatureMethod_HMAC_SHA1()
         
-        self._verify_browser_command()
-
 
     # -----------------------------------------------------------------------
     def authenticate(self, need_auth, block_for_auth):
         need_auth()
         token = self._get_request_token()
         url = self._get_authorize_url(token)
-        verifier = block_for_auth(True)
+        verifier = block_for_auth(True, url)
         self._verify_verifier(token, verifier)
     
     
@@ -158,6 +156,9 @@ class LinkedInApi():
         try:
             token = oauth.OAuthToken.from_string(response)
         except Exception, e:
+            import traceback
+            traceback.print_exc()
+            print response
             raise Exception("Authorization failure - failed to get request token")
         return token
 
@@ -184,8 +185,8 @@ class LinkedInApi():
         connection.request(oauth_request.http_method, self.ACCESS_TOKEN_URL, headers=oauth_request.to_header()) 
         response = connection.getresponse()
         token_str = response.read()
-        if "ouath_problem" in token_str:
-            raise Exception("Authorization failure - failed to get access token")
+        if 'oauth_problem' in token_str:
+            raise Exception("Authorization failure - failed to get access token (" + token_str + ")")
         self._store_access_token_in_gconf(token_str)
         return oauth.OAuthToken.from_string(token_str)
 
@@ -197,15 +198,7 @@ class LinkedInApi():
         except Exception, e:
             import traceback
             traceback.print_exc()
-            raise Exception("LinkedIn authorization failed, try again (" + e + ")")
-
-
-    # -----------------------------------------------------------------------
-    def _verify_browser_command(self):
-        # -- Check the environment is going to work...
-        # FIXME: duplication
-        if (self._gc.get_string('/desktop/gnome/url-handlers/http/command') == 'epiphany %s'):
-            raise Exception('Browser in gconf invalid (see NB#136012). Installation error.')
+            raise Exception("LinkedIn authorization failed, try again")
 
 
     # -----------------------------------------------------------------------