title: AuthFailed with django-social-auth & Facebook authentication
body: <p>I'm using django-social-auth to do Facebook server-side authentication, and I am getting this error that I've been unable to track down:  AuthFailed('There was an error authenticating the app').</p>
  
  <p>I do NOT get this error when I test locally and I have the Facebook app site URL pointing to localhost.</p>
  
  <p>However, I do get this error every time I point the Facebook app site URL to my dev instance -- e.g., <a href="https://dev.mydomain.com" rel="nofollow">https://dev.mydomain.com</a>.</p>
  
  <p>I have not been able to find a list of things that might cause the AuthFailed('There was an error authenticating the app') error.</p>
  
  <p>Also, I have not been able to find others that have used django-social-auth successfully and solved this problem already.</p>
  
  <p>I've found some useful info at the following:
  <a href="https://github.com/omab/django-social-auth/blob/master/doc/configuration.rst" rel="nofollow">https://github.com/omab/django-social-auth/blob/master/doc/configuration.rst</a><br>
  <a href="http://django-social-auth.readthedocs.org/en/latest/" rel="nofollow">http://django-social-auth.readthedocs.org/en/latest/</a><br>
  <a href="https://developers.facebook.com/docs/technical-guides/login/" rel="nofollow">https://developers.facebook.com/docs/technical-guides/login/</a>    <a href="https://developers.facebook.com/docs/howtos/login/server-side-login/" rel="nofollow">https://developers.facebook.com/docs/howtos/login/server-side-login/</a></p>
  
  <p>Lastly, I want to do server-side authentication because I want to retrieve users' name, email, and photo.  However, if that can be done via client-side authentication, I guess I could try that.</p>
  
  <p>Code below...</p>
  
  <p>in settings.py:</p>
  
  <pre><code>LOGIN_URL = '/account/login/'
  LOGIN_REDIRECT_URL = '/'
  LOGIN_ERROR_URL = '/account/login/' # added when trying to debug Facebook error
  
  AUTHENTICATION_BACKENDS = (
      'social_auth.backends.facebook.FacebookBackend',
      'django.contrib.auth.backends.ModelBackend',
  )
  
  FACEBOOK_APP_ID = 'xxx'
  FACEBOOK_API_SECRET = 'xxxxxx'
  FACEBOOK_EXTENDED_PERMISSIONS = ['email']
  
  SOCIAL_AUTH_CREATE_USERS = True
  SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
  SOCIAL_AUTH_DEFAULT_USERNAME = 'socialauth_user'
  SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
  SOCIAL_AUTH_ERROR_KEY = 'socialauth_error'
  SOCIAL_AUTH_REDIRECT_IS_HTTPS = True    # force https in dev and production
  
  # is SOCIAL_AUTH_LOGIN_REDIRECT_URL or SOCIAL_AUTH_BACKEND_ERROR_URL needed???
  
  SOCIAL_AUTH_PIPELINE = (
      'social_auth.backends.pipeline.social.social_auth_user',
      'social_auth.backends.pipeline.associate.associate_by_email',
      'social_auth.backends.pipeline.misc.save_status_to_session',
      'apps.dsa_pipeline.redirect_to_form',
      'apps.dsa_pipeline.username',
      'apps.dsa_pipeline.phone',
      'social_auth.backends.pipeline.user.create_user',
      'social_auth.backends.pipeline.social.associate_user',
      'social_auth.backends.pipeline.social.load_extra_data',
      'social_auth.backends.pipeline.user.update_user_details',
      'apps.dsa_pipeline.profile',
  ) 
  </code></pre>
  
  <p>in dsa_pipeline.py:</p>
  
  <pre><code>from django.http import HttpResponseRedirect
  from urllib2 import urlopen
  
  def redirect_to_form(*args, **kwargs):
      if not kwargs['request'].session.get('saved_username') and kwargs.get('user') is None:
          return HttpResponseRedirect('/account/signup_dsa/')
  
  def username(request, *args, **kwargs):
      if kwargs.get('user'):
          username = kwargs['user'].username
      else:
          username = request.session.get('saved_username')
      return {'username': username}
  
  def phone(request, *args, **kwargs):
      if kwargs.get('phone'):
          phone = kwargs['phone'].phone
      else:
          phone = request.session.get('saved_phone')
      return {'phone': phone}
  
  def profile(backend, details, response, social_user, uid, user, *args, **kwargs):
      profile = user.profile
      if not profile.phone:
          ph = kwargs.get('phone')
          if ph:
              profile.phone = ph
              profile.save()
  </code></pre>
  
  <p>in urls.py:</p>
  
  <pre><code>urlpatterns = patterns("",
      url(r"^$", direct_to_template, {"template": "homepage.html"}, name="home"),
      url(r"^admin/", include(admin.site.urls)),
  
      # profiles
      url(r'^', include("apps.profiles.urls")),
      url(r"^account/signup/$", SignupView.as_view(), name="account_signup"),
      url(r"^account/signup_dsa/$", SignupViewDSA.as_view(), name="account_signup_dsa"), 
      url(r"^account/", include("account.urls")),
  
      # Django Social Auth
      url(r'', include('social_auth.urls')),
  </code></pre>
  
  <p>Thanks for any help!</p>