Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorAndrew Flegg <andrew@bleb.org>
Sun, 19 Dec 2010 13:06:23 +0000 (13:06 +0000)
committerAndrew Flegg <andrew@bleb.org>
Sun, 2 Jan 2011 19:53:45 +0000 (19:53 +0000)
package/src/org/maemo/hermes/engine/linkedin/api.py
package/src/org/maemo/hermes/engine/service.py

index ebb0c60..363b2e9 100644 (file)
@@ -5,6 +5,7 @@ from oauth import oauth
 from xml.dom.minidom import parseString
 from org.maemo.hermes.engine.phonenumber import PhoneNumber
 from org.maemo.hermes.engine.friend import Friend
+from org.maemo.hermes.engine.service import CredentialsExpiredException
 
 class LinkedInApi():
     """LinkedIn API for Hermes.
@@ -123,13 +124,16 @@ class LinkedInApi():
         
         # look for errors
         errors = dom.getElementsByTagName('error')
-        if (errors and len(errors) > 0):
+        if errors and len(errors) > 0:
             details = ""
             try:
                 details = " (" + extract(errors[0], "message") + ")"
             except:
                 pass
-            raise Exception("LinkedIn communication errors detected" + details)
+            if details.startswith('([unauth'):
+                raise CredentialsExpiredException('linkedin')
+            else:
+                raise Exception("LinkedIn communication errors detected" + details)
         
         friends = []
         people = dom.getElementsByTagName('person')
index 3d7d8bb..f652a60 100644 (file)
@@ -67,3 +67,15 @@ class Service:
            be added to."""
            
         pass
+
+
+# ---------------------------------------------------------------------------
+class CredentialsExpiredException(Exception):
+    """Used to indicate that the credentials provided, say via OAuth,
+       have expired or are incorrect.
+       
+       Copyright (c) Andrew Flegg <andrew@bleb.org> 2010.
+       Released under the Artistic Licence."""
+    
+    
+    pass
\ No newline at end of file

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment