django 1.6 + django-allauth facebook authentication error

1,314 views
Skip to first unread message

Nobin Mathew

unread,
Dec 24, 2013, 2:05:26 AM12/24/13
to django...@googlegroups.com
Hi,

I am writing a django website using django-allauth for facebook authentication.

When I sign into facebook(after giving username and passwd) from my local development server( `<`http://127.0.0.1:8001/gallery/`>` ) I get following error:

***************
Social Network Login Failure

An error occurred while attempting to login via your social network account.
***************

and url in browser while on this error is http://localhost:8001/gallery/accounts/facebook/login/callback/.


Settings:

Facebook.com app setting:
AppId =XXX(not shown)
APP secret =xxx(not shown)

Wbsite:Site URL = http://localhost:8001/gallery/accounts/facebook/login/callback/

Django setting(local):

LOGIN_REDIRECT_URL = 'http://localhost:8001/gallery/accounts/facebook/login/callback/'

    SOCIALACCOUNT_PROVIDERS = {
     'facebook': {
                'SCOPE': ['email', 'publish_stream'],
                'AUTH_PARAMS': { 'auth_type': 'reauthenticate' },
                'METHOD': 'oauth2'  # instead of 'oauth2'
     }
    }

ACCOUNT_LOGOUT_REDIRECT_URL = '/gallery'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_AUTO_SIGNUP = True
ACCOUNT_EMAIL_VERIFICATION = False



and my base.html template is (not full):
  <body>
                 {% load url from future %}
                 {% load socialaccount %}
                 {% if request.user.is_authenticated %}
                     <a href="{% url 'account_logout' %}">Logout</a>
                 {% else %}
                     <a href="{% url 'account_signup' %}">Sign Up</a>
                     <a href="{% url 'account_login' %}">Log in</a>
                     <a href="{% provider_login_url 'facebook' method='oauth2' %}">
                     Sign Up/Login with Facebook</a>
                 {% endif %}
  </body>   
  
        
          

When I am error page  http://localhost:8001/gallery/accounts/facebook/login/callback/ it says I am logged in (i.e. displays Logout and user is authenticated).

Any Idea why this happens? Any help will be appreciated.






Timothy W. Cook

unread,
Dec 24, 2013, 4:58:32 AM12/24/13
to django...@googlegroups.com
My guess is because FB can't redirect to a localhost URL. You could probably use something like no-ip.org and setup a reachable URL.

HTH,
Tim



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aba71009-2066-48aa-8502-0e90699295e3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Avraham Serour

unread,
Dec 24, 2013, 5:20:59 AM12/24/13
to django...@googlegroups.com
facebook can indeed redirect to localhost, I've done it before, the problem is:
1 - you need to use localhost, 12.7.0.0.1 won't work
2 - you need a separate app id for that, just create a general one for localhost development


Scot Hacker

unread,
Dec 24, 2013, 3:11:51 PM12/24/13
to django...@googlegroups.com

On Monday, December 23, 2013 11:05:26 PM UTC-8, Nobin Mathew wrote:
Hi,

I am writing a django website using django-allauth for facebook authentication.

When I sign into facebook(after giving username and passwd) from my local development server( `<`http://127.0.0.1:8001/gallery/`>` ) I get following error:

 When developing against Facebook, I find it easiest to create a localhost DNS entry emulating the domain registered in the FB app itself. So, if you're on Mac:

sudo vi /etc/hosts

and enter:

127.0.0.1  somedomain.com

And then:

./manage.py runserver somedomain.com:8080

Then just pull up somedomain.com:8080 in your browser and you'll be running a local dev site that FB sees as the production site, so your apps will work.

No such hassle with Twitter or Google.

./s


sachit adhikari

unread,
Feb 5, 2019, 7:17:50 AM2/5/19
to Django users
Anyone having a issue, look at this tutorial : https://www.youtube.com/watch?v=PtVu04V027c
Reply all
Reply to author
Forward
0 new messages