本文整理汇总了Python中social_auth.utils.sanitize_log_data函数的典型用法代码示例。如果您正苦于以下问题:Python sanitize_log_data函数的具体用法?Python sanitize_log_data怎么用?Python sanitize_log_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanitize_log_data函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: user_data
def user_data(self, access_token, *args, **kwargs):
"""
Grab user profile information from facebook.
returns: dict or None
"""
data = None
params = backend_setting(self, self.EXTRA_PARAMS_VAR_NAME, {})
params['access_token'] = access_token
url = FACEBOOK_ME + urlencode(params)
try:
response = dsa_urlopen(url)
data = json.load(response)
except ValueError:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Could not load user data from Facebook.',
exc_info=True, extra=extra)
except HTTPError:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Error validating access token.',
exc_info=True, extra=extra)
raise AuthTokenError(self)
else:
log('debug', 'Found user data for token %s',
sanitize_log_data(access_token), extra={'data': data})
return data
开发者ID:serkanozer,项目名称:django-social-auth,代码行数:28,代码来源:facebook.py
示例2: user_data
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
data = None
params = backend_setting(self, self.EXTRA_PARAMS_VAR_NAME, {})
params['access_token'] = access_token
url = FACEBOOK_ME + urlencode(params)
try:
response = requests.get(url)
if response.status_code == 200:
data = simplejson.loads(response.text)
else:
raise AuthTokenError()
except ValueError:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Could not load user data from Facebook.',
exc_info=True, extra=extra)
except requests.RequestException:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Error validating access token.',
exc_info=True, extra=extra)
raise AuthTokenError(self)
else:
log('debug', 'Found user data for token %s',
sanitize_log_data(access_token), extra={'data': data})
return data
开发者ID:talos,项目名称:django-social-auth-norel,代码行数:26,代码来源:facebook.py
示例3: user_data
def user_data(self, access_token):
"""Loads user data from service"""
data = None
url = FACEBOOK_ME + urlencode({'access_token': access_token})
try:
data = simplejson.load(urlopen(url))
logger.debug('Found user data for token %s',
sanitize_log_data(access_token),
extra=dict(data=data))
except ValueError:
params.update({'access_token': sanitize_log_data(access_token)})
logger.error('Could not load user data from Facebook.',
exc_info=True, extra=dict(data=params))
return data
开发者ID:Sanoma-Media-Games,项目名称:django-social-auth,代码行数:15,代码来源:facebook.py
示例4: user_data
def user_data(self, access_token):
"""Loads user data from service"""
params = {'access_token': access_token,}
url = 'https://graph.facebook.com/me?' + urlencode(params)
try:
data = simplejson.load(urlopen(url))
logger.debug('Found user data for token %s',
sanitize_log_data(access_token),
extra=dict(data=data))
return data
except ValueError:
params.update({'access_token': sanitize_log_data(access_token)})
logger.error('Could not load user data from Facebook.',
exc_info=True, extra=dict(data=params))
return None
开发者ID:rabahs,项目名称:django-social-auth,代码行数:16,代码来源:facebook.py
示例5: user_data
def user_data(self, access_token):
"""Loads user data from service"""
data = None
url = FACEBOOK_ME + urlencode({'access_token': access_token})
try:
data = simplejson.load(urlopen(url))
except ValueError:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Could not load user data from Facebook.',
exc_info=True, extra=extra)
else:
log('debug', 'Found user data for token %s',
sanitize_log_data(access_token),
extra=dict(data=data))
return data
开发者ID:AdvisorDeck,项目名称:django-social-auth,代码行数:16,代码来源:facebook.py
示例6: user_data
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
data = None
params = setting('FACEBOOK_PROFILE_EXTRA_PARAMS', {})
params['access_token'] = access_token
url = FACEBOOK_ME + urlencode(params)
try:
data = simplejson.load(urlopen(url))
except ValueError:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Could not load user data from Facebook.',
exc_info=True, extra=extra)
except HTTPError:
extra = {'access_token': sanitize_log_data(access_token)}
log('error', 'Error validating access token.',
exc_info=True, extra=extra)
raise AuthTokenError(self)
else:
log('debug', 'Found user data for token %s',
sanitize_log_data(access_token), extra={'data': data})
return data
开发者ID:HengeSense,项目名称:www.freedomsponsors.org,代码行数:22,代码来源:facebook.py
示例7: authenticate
def authenticate(self, *args, **kwargs):
"""Authenticate user using social credentials
Authentication is made if this is the correct backend, backend
verification is made by kwargs inspection for current backend
name presence.
"""
# Validate backend and arguments. Require that the Social Auth
# response be passed in as a keyword argument, to make sure we
# don't match the username/password calling conventions of
# authenticate.
if not (self.name and kwargs.get(self.name) and 'response' in kwargs):
return None
# Pull in basics from the backend
response = kwargs.get('response')
details = self.get_user_details(response)
uid = self.get_user_id(details, response)
is_new = False
user = kwargs.get('user')
# If we've got an associated user, we're good to go
try:
social_user = self.get_social_auth_user(uid)
except UserSocialAuth.DoesNotExist:
# Oops! We don't know who you are!
# There's two ways this can happen
# 1. You're new here and we'll need to register you if that's the kind of place this is
# 2. You've been here a while, but need to link this profile
# Creating users is a pain, but we need to do that first so that we can link later
if user is None: # You're new here!
# Check to see if we've been told to create new users
# First, we need permission from settings in the form of CREATE_USERS
# Then we need to make sure that the kwarg for create_user isn't False
if CREATE_USERS and kwargs.get('create_user', True):
# We can create the user! JOY!
# But wait! Shouldn't we check to see if there's already a user with this e-mail address and just link the two?
email = details.get('email')
if email and ASSOCIATE_BY_MAIL:
# try to associate accounts registered with the same email
# address, only if it's a single object. ValueError is
# raised if multiple objects are returned
try:
user = User.objects.get(email=email)
except MultipleObjectsReturned:
raise ValueError('Not unique email address supplied')
except User.DoesNotExist:
user = None
# OK. we're finally ready to create the account if we got to this point without a user
if not user:
username = self.username(details)
print('Creating new user with username %s and email %s',
username, sanitize_log_data(email))
logger.debug('Creating new user with username %s and email %s',
username, sanitize_log_data(email))
user = User.objects.create_user(username=username,
email=email)
is_new = True
else:
# Wait a second! We can't create a user! We're forbidden by the settings or the kwargs
# Send signal for cases where tracking failed registering
# is useful.
socialauth_not_registered.send(sender=self.__class__,
uid=uid,
response=response,
details=details)
return None
# Now, we've either created a user or we've returned a None. Link!
try:
social_user = self.associate_auth(user, uid, response, details)
except IntegrityError:
# Protect for possible race condition, those bastard with FTL
# clicking capabilities
social_user = self.get_social_auth_user(uid)
# Raise ValueError if this account was registered by another user.
if user and user != social_user.user:
raise ValueError('Account already in use.', social_user)
user = social_user.user
# Flag user "new" status
setattr(user, 'is_new', is_new)
# Update extra_data storage, unless disabled by setting
if LOAD_EXTRA_DATA:
extra_data = self.extra_data(user, uid, response, details)
if extra_data and social_user.extra_data != extra_data:
social_user.extra_data = extra_data
social_user.save()
user.social_user = social_user
# Update user account data.
self.update_user_details(user, response, details, is_new)
return user
开发者ID:alexlovelltroy,项目名称:django-social-auth,代码行数:94,代码来源:__init__.py
示例8: authenticate
def authenticate(self, *args, **kwargs):
"""Authenticate user using social credentials
Authentication is made if this is the correct backend, backend
verification is made by kwargs inspection for current backend
name presence.
"""
# Validate backend and arguments. Require that the Social Auth
# response be passed in as a keyword argument, to make sure we
# don't match the username/password calling conventions of
# authenticate.
if not (self.name and kwargs.get(self.name) and 'response' in kwargs):
return None
response = kwargs.get('response')
details = self.get_user_details(response)
uid = self.get_user_id(details, response)
is_new = False
user = kwargs.get('user')
try:
social_user = self.get_social_auth_user(uid)
except UserSocialAuth.DoesNotExist:
if user is None: # new user
if not CREATE_USERS or not kwargs.get('create_user', True):
# Send signal for cases where tracking failed registering
# is useful.
socialauth_not_registered.send(sender=self.__class__,
uid=uid,
response=response,
details=details)
return None
email = details.get('email')
if email and ASSOCIATE_BY_MAIL:
# try to associate accounts registered with the same email
# address, only if it's a single object. ValueError is
# raised if multiple objects are returned
try:
user = User.objects.get(email=email)
except MultipleObjectsReturned:
raise ValueError('Not unique email address supplied')
except User.DoesNotExist:
user = None
if not user:
username = self.username(details)
logger.debug('Creating new user with username %s and email %s',
username, sanitize_log_data(email))
user = User.objects.create_user(username=username,
email=email)
is_new = True
try:
social_user = self.associate_auth(user, uid, response, details)
except IntegrityError:
# Protect for possible race condition, those bastard with FTL
# clicking capabilities
social_user = self.get_social_auth_user(uid)
# Raise ValueError if this account was registered by another user.
if user and user != social_user.user:
raise ValueError('Account already in use.', social_user)
user = social_user.user
# Flag user "new" status
setattr(user, 'is_new', is_new)
# Update extra_data storage, unless disabled by setting
if LOAD_EXTRA_DATA:
extra_data = self.extra_data(user, uid, response, details)
if extra_data and social_user.extra_data != extra_data:
social_user.extra_data = extra_data
social_user.save()
user.social_user = social_user
# Update user account data.
self.update_user_details(user, response, details, is_new)
return user
开发者ID:DrAA,项目名称:django-social-auth,代码行数:79,代码来源:__init__.py
注:本文中的social_auth.utils.sanitize_log_data函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论