EVERNOTE_CONSUMER_KEY = ''
EVERNOTE_CONSUMER_SECRET = ''
+- To test in the sandbox add to settings::
+
+ EVERNOTE_DEBUG = True
+
.. _Evernote API Key form: http://dev.evernote.com/support/api_key.php
No extra configurations are needed to make this work.
"""
+from urllib2 import HTTPError
try:
from urlparse import parse_qs
parse_qs # placate pyflakes
from oauth2 import Token
from social_auth.utils import setting
-from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
+from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME,\
+ exceptions
if setting('EVERNOTE_DEBUG', False):
def access_token(self, token):
"""Return request for access token value"""
request = self.oauth_request(token, self.ACCESS_TOKEN_URL)
- response = self.fetch_response(request)
+
+ try:
+ response = self.fetch_response(request)
+ except HTTPError, e:
+ # Evernote returns a 401 error when AuthCanceled
+ if e.code == 401:
+ raise exceptions.AuthCanceled(self)
+ else:
+ raise
+
params = parse_qs(response)
# evernote sents a empty secret token, this way it doesn't fires up the