]> git.parisson.com Git - django-social-auth.git/commitdiff
Small code styles changes and docs about evernote backend. Refs #341
authorMatías Aguirre <matiasaguirre@gmail.com>
Mon, 7 May 2012 22:03:54 +0000 (19:03 -0300)
committerMatías Aguirre <matiasaguirre@gmail.com>
Mon, 7 May 2012 22:03:54 +0000 (19:03 -0300)
README.rst
doc/backends/evernote.rst [new file with mode: 0644]
doc/backends/index.rst
doc/contributions.rst
social_auth/backends/contrib/evernote.py

index c33fad04ee94c70249f33548d3b74a6b783a09a8..79cafc87148a953067d5b9e8e94cd7efab44a2f7 100644 (file)
@@ -48,6 +48,7 @@ credentials, some features are:
     * `MSN Live Connect OAuth2`_
     * `Skyrock OAuth`_
     * `Yahoo OAuth`_
+    * `Evernote OAuth`_
 
 - Basic user data population and signaling, to allows custom fields values
   from providers response
@@ -996,6 +997,19 @@ OAuth 1.0 workflow, useful if you are planning to use Yahoo's API.
       YAHOO_CONSUMER_KEY = ''
       YAHOO_CONSUMER_SECRET = ''
 
+Evernote OAuth
+^^^^^^^^^^^^^^
+
+Evernote OAuth 1.0 workflow.
+
+- Register a new application at `Evernote API Key form`_.
+
+- Fill ``Consumer Key`` and ``Consumer Secret`` values in the settings::
+
+      EVERNOTE_CONSUMER_KEY = ''
+      EVERNOTE_CONSUMER_SECRET = ''
+
+
 Testing
 -------
 
@@ -1190,6 +1204,11 @@ Attributions to whom deserves:
 
   - Skyrock.com support
 
+- hassek_ (Tomas Henriquez)
+
+  - Evernote support
+
+
 Copyrights
 ----------
 
@@ -1288,3 +1307,5 @@ Base work is copyrighted by:
 .. _Skyrock API Documentation: http://www.skyrock.com/developer/documentation/
 .. _Yahoo OAuth: http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html
 .. _Yahoo Developer Center: https://developer.apps.yahoo.com/projects/
+.. _Evernote API Key form: http://dev.evernote.com/support/api_key.php
+.. _hassek: https://github.com/hassek
diff --git a/doc/backends/evernote.rst b/doc/backends/evernote.rst
new file mode 100644 (file)
index 0000000..25a17a8
--- /dev/null
@@ -0,0 +1,13 @@
+Evernote OAuth
+==============
+
+Evernote OAuth 1.0 workflow.
+
+- Register a new application at `Evernote API Key form`_.
+
+- Fill ``Consumer Key`` and ``Consumer Secret`` values in the settings::
+
+      EVERNOTE_CONSUMER_KEY = ''
+      EVERNOTE_CONSUMER_SECRET = ''
+
+.. _Evernote API Key form: http://dev.evernote.com/support/api_key.php
index 3155f8ca4ddb935b092f92f204ba36a511afbab4..5172998fe186044ff2206336e8cba476504eb0d0 100644 (file)
@@ -21,4 +21,5 @@ Contents:
    vkontakte
    live
    skyrock
-   yahoo
No newline at end of file
+   yahoo
  evernote
index b017b0932a3de848914883b0998eaad791923844..d832cd40b51e309423bd9e2dce420ee7f16f620e 100644 (file)
@@ -40,6 +40,12 @@ andrusha_ (Andrew Korzhuev)
   * MSN Live Connect support
   * Yahoo OAuth 1.0 support
 
+niQo_ (Nicolas Quiénot)
+  * Skyrock.com support
+
+hassek_ (Tomas Henriquez)
+  * Evernote support
+
 .. _caioariede: https://github.com/caioariede
 .. _krvss: https://github.com/krvss
 .. _jezdez: https://github.com/jezdez
@@ -53,3 +59,5 @@ andrusha_ (Andrew Korzhuev)
 .. _maraujop: https://github.com/maraujop
 .. _bedspax: https://github.com/bedspax
 .. _python-oauth2: https://github.com/simplegeo/python-oauth2
+.. _niQo: https://github.com/niQo
+.. _hassek: https://github.com/hassek
index a8027b651ec01386b483e1a1b06cc61807d4b798..cdd4fd79bee79a46112ab92d4d860a4f025d649a 100644 (file)
@@ -16,21 +16,20 @@ from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
 
 
 if setting('EVERNOTE_DEBUG', False):
-    EVERNOTE_SERVER = "sandbox.evernote.com"
+    EVERNOTE_SERVER = 'sandbox.evernote.com'
 else:
     EVERNOTE_SERVER = 'www.evernote.com'
 
-EVERNOTE_REQUEST_TOKEN_URL = 'https://%s/oauth' % \
-                                    EVERNOTE_SERVER
-EVERNOTE_ACCESS_TOKEN_URL = 'https://%s/oauth' % \
-                                    EVERNOTE_SERVER
-EVERNOTE_AUTHORIZATION_URL = 'https://%s/OAuth.action' % \
-                                    EVERNOTE_SERVER
+EVERNOTE_REQUEST_TOKEN_URL = 'https://%s/oauth' % EVERNOTE_SERVER
+EVERNOTE_ACCESS_TOKEN_URL = 'https://%s/oauth' % EVERNOTE_SERVER
+EVERNOTE_AUTHORIZATION_URL = 'https://%s/OAuth.action' % EVERNOTE_SERVER
 
 
 class EvernoteBackend(OAuthBackend):
-    """Evernote OAuth authentication backend
-       Possible Values:
+    """
+    Evernote OAuth authentication backend.
+
+    Possible Values:
        {'edam_expires': ['1367525289541'],
         'edam_noteStoreUrl': ['https://sandbox.evernote.com/shard/s1/notestore'],
         'edam_shard': ['s1'],
@@ -38,7 +37,6 @@ class EvernoteBackend(OAuthBackend):
         'edam_webApiUrlPrefix': ['https://sandbox.evernote.com/shard/s1/'],
         'oauth_token': ['S=s1:U=1e3c1:E=13e66dbee45:C=1370f2ac245:P=185:A=my_user:H=411443c5e8b20f8718ed382a19d4ae38']}
     """
-
     name = 'evernote'
 
     EXTRA_DATA = [
@@ -50,9 +48,10 @@ class EvernoteBackend(OAuthBackend):
 
     def get_user_details(self, response):
         """Return user details from Evernote account"""
-        return {USERNAME: response["edam_userId"],
-                'email': '',
-                }
+        return {
+            USERNAME: response['edam_userId'],
+            'email': '',
+        }
 
     def get_user_id(self, details, response):
         return response['edam_userId'][0]
@@ -74,20 +73,22 @@ class EvernoteAuth(ConsumerBasedOAuth):
         response = self.fetch_response(request)
         params = parse_qs(response)
 
-        # evernote sents a empty secret token, this way it doesn't fires up the exception
-        response = response.replace("oauth_token_secret=", "oauth_token_secret=None")
+        # evernote sents a empty secret token, this way it doesn't fires up the
+        # exception
+        response = response.replace('oauth_token_secret=',
+                                    'oauth_token_secret=None')
         token = Token.from_string(response)
 
         token.user_info = params
         return token
 
     def user_data(self, access_token, *args, **kwargs):
-        """Return user data provided """
-
+        """Return user data provided"""
         # drop lists
         return dict([(key, val[0]) for key, val in
             access_token.user_info.items()])
 
+
 # Backend definition
 BACKENDS = {
     'evernote': EvernoteAuth,