Safari
Safari

Reputation: 11935

Django-Allauth and django-facebook to retrieve Facebook profile images

I integrated django-rest-auth and django-allauth for user registration/login using Facebook.

Now, I can authenticate (and I can create) the Facebook user and I can retrieve some basic informations like e-mail, first name, last name...

Now I need also to retrieve some profile images (last 3 user profile images) about the user at registration of it in my platform.

I'm confused because I can't use allauth to take also these informations from Facebook so, probably, I need to take it directly using Facebook GraphAPI (is correct this my solution?)

Is a good solution the integration of django_facebook?

Upvotes: 0

Views: 1380

Answers (2)

Leo
Leo

Reputation: 71

The photo can be retrieved directly with the user UID and this URL:

http://graph.facebook.com/UID/picture?width=40&height=40

In function:

 fb_uid = SocialAccount.objects.filter(user_id=self.user.id, provider='facebook')

 if len(fb_uid):
         return "http://graph.facebook.com/{}/picture?width=40&height=40".format(fb_uid[0].uid)

Upvotes: 1

Mateusz Sikora
Mateusz Sikora

Reputation: 1

I'm not entire sure, but I think you will get access to the user's photos when you add "user_photos" to scope list in facebook configuration. Did you try it?

Here is a link to django allauth documentation: http://django-allauth.readthedocs.org/en/latest/providers.html#facebook

Upvotes: 0

Related Questions