5

I am trying to work with django-allauth. I followed the instructions at github page and done following:

  1. Added allauth urls into urls.py

    urlpatterns += patterns ('',
        url('^accounts/', include('allauth.urls')),
        url('^accounts/profile/$', ProfileView.as_view(), name='ProfileView'),
        url('^login/$', login, name='account_login'),
        url('^logout/$', logout, name='account_logout'),
        url('^login/cancelled/$', login_cancelled, name='socialaccount_login_cancelled'),
        url('^login/error/$', login_error, name='socialaccount_login_error'),
    )
    
  2. Updated TEMPLATE_CONTEXT_DIRS, TEMPLATE_CONTEXT_PROCESSORS, AUTHENTICATION_BACKENDS and INSTALLED_APPS. Also added ACCOUNT_AUTHENTICATION_METHOD = "username_email"

  3. Added Key and Secret for twitter in the Social apps table.

  4. Copied django-allauth templates to my app's directory and modified it. I can see all the templates working fine like /accounts/signup/ and /accounts/social/connections/.

Now, from connections or signup when I click Twitter link /accounts/twitter/login/ I ended up with the following error:

Social Network Login Failure

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

Am I missing something? May be some stupid mistake (Twitter login url? No clues!). I also tried to find some tutorials based on the latest codebase but unable to find any. django-allauth example on github wasn't of any help. Please help. Also, please feel free to provide me any links or tutorials based on the latest codebase.

Thanks in advance.

4

1 回答 1

9

I am a beginner so you can expect some stupid mistakes from people like me but I try to learn. I spent many hours trying to resolve this. Finally the issue turns out to be Twitter App Key Settings:

I get "Social Network Login Failure" error because my Twitter App settings are not configured for the localhost. Make sure you have the following settings configured in your Twitter App for your localhost (development machine):

Callback URL: http://127.0.0.1:8000/

NOTE: If you want to use it for production server then you need to set Callback to your domain name as follows:

Callback URL: http://Your_Domain_Name.com

OR better use another set of Keys specifically for production use only.

BONUS : If you are using django-social-auth and you don't have these settings configured then you may end up with 401 Unauthorized error.

于 2012-08-03T02:03:58.603 回答