You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.
class GidsyFacebookCallback(DefaultFacebookCallback):
def update_profile_from_graph(self, request, access, token, profile):
user_data = self.fetch_user_data(request, access, token)
user = profile.user
user.first_name = user_data["first_name"]
user.last_name = user_data["last_name"]
user.email = user_data["email"]
user.save()
for k, v in user_data.items():
if k !='id' and hasattr(profile, k):
setattr(profile, k, v)
logger.debug("DefaultFacebookCallback.update_profile_from_graph"\
": updating profile %s to %s" % (k,v))
return profile
def create_profile(self, request, access, token, user):
if hasattr(settings, 'AUTH_PROFILE_MODULE'):
profile_model = get_model(*settings.AUTH_PROFILE_MODULE.split('.'))
profile, created = profile_model.objects.get_or_create(
user = user,
)
profile = self.update_profile_from_graph(request, access, token, profile)
profile.save()
else:
# Do nothing because users have no site profile defined
# TODO - should we pass a warning message? Raise a SiteProfileNotAvailable error?
logger.warning("DefaultFacebookCallback.create_profile: unable to" \
"create/update profile as no AUTH_PROFILE_MODULE setting" \
"has been defined")
pass
def create_user(self, request, access, token, user_data):
identifier = self.identifier_from_data(user_data)
username = str(identifier)
if User.objects.filter(username=username).count():
logger.warning("DefaultFacebookCallback.create_user: A user for" \
"was already found, when asked to create a user for %s"
% username)
user = User.objects.get(username=username)
else:
user = User(username=str(identifier))
user.set_unusable_password()
user.save()
logger.debug("DefaultFacebookCallback.create_user: new django" \
"user created for %s" % username)
self.create_profile(request, access, token, user)
self.login_user(request, user)
#persist access token
#access.persist(user, token, identifier=identifier)
return user
gidsy_facebook_callback = GidsyFacebookCallback()
As you see it does not add much new functionality. Once I use it the UserAssociation is not stored anymore. Furthermore I tried to do that myself then with the line:
I tried writing my custom callback:
class GidsyFacebookCallback(DefaultFacebookCallback):
gidsy_facebook_callback = GidsyFacebookCallback()
As you see it does not add much new functionality. Once I use it the UserAssociation is not stored anymore. Furthermore I tried to do that myself then with the line:
access.persist(user, token, identifier=identifier)
however, that did not work due to:
'OAuthAccess' object has no attribute 'persist'
I actually got the same error before when I tried to do my own function for:
def lookup_user(self, request, access, user_data):
return access.lookup_user(identifier=self.identifier_from_data(user_data))
Am I hitting a bug or am I using it wrong?
Thanks for any help.
The text was updated successfully, but these errors were encountered: