Settings:
LIVE_CLIENT_ID
LIVE_CLIENT_SECRET
-LIVE_EXTENDED_PERMISSIONS (default: wl.basic, wl.emails)
+LIVE_EXTENDED_PERMISSIONS (defaults are: wl.basic, wl.emails)
References:
* oAuth http://msdn.microsoft.com/en-us/library/live/hh243649.aspx
* Scopes http://msdn.microsoft.com/en-us/library/live/hh243646.aspx
* REST http://msdn.microsoft.com/en-us/library/live/hh243648.aspx
+
+Throws:
+AuthUnknownError - if user data retrieval fails
"""
from urllib import urlencode, urlopen
from social_auth.utils import setting
from social_auth.backends import BaseOAuth2, OAuthBackend, USERNAME
+from social_auth.backends.exceptions import AuthUnknownError
# Live Connect configuration
LIVE_ACCESS_TOKEN_URL = 'https://login.live.com/oauth20_token.srf'
LIVE_USER_DATA_URL = 'https://apis.live.net/v5.0/me'
LIVE_SERVER = 'live.com'
-LIVE_EXTENDED_PERMISSIONS = ['wl.basic', 'wl.emails']
+LIVE_DEFAULT_PERMISSIONS = ['wl.basic', 'wl.emails']
class LiveBackend(OAuthBackend):
def get_scope(self):
"""Return list with needed access scope"""
- return setting('LIVE_EXTENDED_PERMISSIONS', LIVE_EXTENDED_PERMISSIONS)
+ return LIVE_DEFAULT_PERMISSIONS + setting('LIVE_EXTENDED_PERMISSIONS', [])
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
})
try:
return simplejson.load(urlopen(url))
- except ValueError:
- return None
+ except (ValueError, IOError):
+ raise AuthUnknownError("Error during profile retrieval, please, try again later")
# Backend definition
* http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html
* http://developer.yahoo.com/social/rest_api_guide/introspective-guid-resource.html
* http://developer.yahoo.com/social/rest_api_guide/extended-profile-resource.html
+
+Scopes:
+To make this extension works correctly you have to have at least
+Yahoo Profile scope with Read permission
+
+Throws:
+AuthUnknownError - if user data retrieval fails (guid or profile)
"""
from django.utils import simplejson
from social_auth.utils import setting
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
+from social_auth.backends.exceptions import AuthUnknownError
# Google OAuth base configuration
return response['guid']
def get_user_details(self, response):
- """Return user details from Orkut account"""
+ """Return user details from Yahoo Profile"""
fname = response.get('givenName')
lname = response.get('familyName')
return {USERNAME: response.get('nickname'),
try:
return simplejson.loads(response)['profile']
except ValueError:
- return None
+ raise AuthUnknownError("Error during profile retrieval, please, try again later")
def _get_guid(self, access_token):
+ """
+ Beause you have to provide GUID for every API request
+ it's also returned during one of OAuth calls
+ """
url = 'http://social.yahooapis.com/v1/me/guid?format=json'
request = self.oauth_request(access_token, url)
response = self.fetch_response(request)
json = simplejson.loads(response)
return json['guid']['value']
except ValueError:
- return 'me'
+ raise AuthUnknownError("Error during user id retrieval, please, try again later")
# Backend definition
BACKENDS = {