django socialauth twitter , google oauth , facebook does not work

1.2k views Asked by At

This is my first post, and I have a problem I could not make it work django OMAB socialauth of three things I just need to google, facebook, and twitter, google works well with open id, but not much twitter and I put in my

settings. py:

TWITTER_CONSUMER_KEY              = '00' this is no real
TWITTER_CONSUMER_SECRET           = '00' this is no real
FACEBOOK_APP_ID                   = '' ihave no key
FACEBOOK_API_SECRET               = ''
LINKEDIN_CONSUMER_KEY             = ''
LINKEDIN_CONSUMER_SECRET          = ''
ORKUT_CONSUMER_KEY                = ''
ORKUT_CONSUMER_SECRET             = ''ihave no key
GOOGLE_OAUTH2_CLIENT_ID           = ''
GOOGLE_OAUTH2_CLIENT_SECRET       = ''
SOCIAL_AUTH_CREATE_USERS          = True
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
SOCIAL_AUTH_DEFAULT_USERNAME      = 'socialauth_user'
SOCIAL_AUTH_COMPLETE_URL_NAME     = 'socialauth_complete'
LOGIN_ERROR_URL                   = '/login/error/'
#SOCIAL_AUTH_USER_MODEL            = 'app.CustomUser'
SOCIAL_AUTH_ERROR_KEY             = 'socialauth_error'
GITHUB_APP_ID                     = ''
GITHUB_API_SECRET                 = ''
FOURSQUARE_CONSUMER_KEY           = ''
FOURSQUARE_CONSUMER_SECRET        = ''

LOGIN_URL          = '/login-form/'
LOGIN_REDIRECT_URL = '/'
LOGIN_ERROR_URL    = '/login-error/'

I am using the example that comes in the zip of OMAB socialauth django , but not working.

When I created my twitter app, I wrote my domain www.sisvei.com , I am testing locally socialauth django ie 127.0.0.1:8000, then sign in with twitter sends me to this url: http://127.0.0.1:8000/login/error/ and a message saying is the Incorrect authentication service

this happens with facebook and google oauth and oauth2

I'm new to django and I this much work comprising this part of django socialath hopefully help me, thank you very much.

2

There are 2 answers

4
Jordan Reiter On

You need to be more specific on "why it doesn't work". Where are you getting the errors?

When debugging a third-party oauth/openid app in Django, generally it boils down to:

  • configuration & keys - did you make sure to obtain all of the necessary API keys for the services you will be using, and to add them to your configuration?
  • urls - did you remember to add the necessary urlpatterns to your base urls.py file?
  • authentication setup on the server - often, you'll need to have a file available or respond with a specific header when the authentication service hits your server. Have you checked to make sure that is set up?
  • databases - have you run syncdb after installing the app? Are all the tables set up?
  • templates - if the third party app requires you to set up templates, do you have them set up?
  • custom views - are you using custom views? If so, try using the built-in views that came with the third party app first, to see if they work

After those are confirmed, you're going to want to be able to see what requests are taking place. Use the debugger included in Chrome/Safari, or get the web developer add-on for Firefox, and look at the network requests as they happen. Do you see HTTP responses other than 200 (say, 404, 500, 403, etc?) those mean that the services aren't responding correctly.

From your error, it looks like you have not correctly set up your callback URL on Twitter. It should be sending you to www.sisvei.com, not 127.0.0.1. Alternatively, check the URL when you get to the Twitter login page -- is the callback URL in the URL, and is it pointing to 127.0.0.1? Then Django is sending it the wrong callback URL.

Finally this:

I wrote my domain www.sisvei.com python does not support this

Is unclear. As far as I know, Python doesn't care what the domain is.

WAIT A MINUTE ...

Are you using runserver? Are you getting the following error?

Error: "www.sisvei.com" is not a valid port number or address:port pair.

If so, there is an easy fix! Just run it like so:

python manage.py runserver www.sisvei.com:80

That should resolve your error if that's what's happening. You're probably running it as

python manage.py runserver 127.0.0.1

127.0.0.1 is a reserved IP address that points back to localhost, your own computer. As a result, it is not possible to use it for authentication or any other purpose outside of programs running on your own machine. See this article for more info.

0
Alex Spangher On

I'm not sure, but I might be having similar problems, oscar. For me, SocialAuth was generating an AuthenticationURL for facebook, foursquare and hotmail, but not for google, twitter or any of the other address it supports. I think it may be something wrong with the API, so I posted an issue on the social-auth google group...you may want to check there to see if anyone updates!!

https://code.google.com/p/socialauth/issues/detail?id=282&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Modified