From 7ea0f5a77f2978357aabf341b745c979533cd024 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Mon, 7 May 2012 19:03:54 -0300 Subject: [PATCH] Small code styles changes and docs about evernote backend. Refs #341 --- README.rst | 21 ++++++++++++++ doc/backends/evernote.rst | 13 +++++++++ doc/backends/index.rst | 3 +- doc/contributions.rst | 8 ++++++ social_auth/backends/contrib/evernote.py | 35 ++++++++++++------------ 5 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 doc/backends/evernote.rst diff --git a/README.rst b/README.rst index c33fad0..79cafc8 100644 --- a/README.rst +++ b/README.rst @@ -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 index 0000000..25a17a8 --- /dev/null +++ b/doc/backends/evernote.rst @@ -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 diff --git a/doc/backends/index.rst b/doc/backends/index.rst index 3155f8c..5172998 100644 --- a/doc/backends/index.rst +++ b/doc/backends/index.rst @@ -21,4 +21,5 @@ Contents: vkontakte live skyrock - yahoo \ No newline at end of file + yahoo + evernote diff --git a/doc/contributions.rst b/doc/contributions.rst index b017b09..d832cd4 100644 --- a/doc/contributions.rst +++ b/doc/contributions.rst @@ -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 diff --git a/social_auth/backends/contrib/evernote.py b/social_auth/backends/contrib/evernote.py index a8027b6..cdd4fd7 100644 --- a/social_auth/backends/contrib/evernote.py +++ b/social_auth/backends/contrib/evernote.py @@ -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, -- 2.39.5