Code Monkey home page Code Monkey logo

django-socialauth's Introduction

WARNING: This app is not maintained anymore

This repo is here for archive purposes, but unmaintained. There are much better social auth libraries.

What it does.

  1. Allow logging in via various providers.
  2. Import contacts from various third party sites, to find out which of your friends already use our service.

Logging In

This is a application to enable authentication via various third party sites. In particular it allows logging in via

  1. Twitter
  2. Gmail
  3. Facebook
  4. Yahoo(Essentially openid)
  5. OpenId
  6. Github
  7. Foursquare

Libs you need to install See requirements.txt use pip install -r requirements.txt to install all dependencies at once Note that you will probably require git and mercurial installed for pip to fetch the requirements.

The API Keys are available from

How it works.

  • Openid: Users need to provide their openid providers. Talk to the providers and login.
  • Yahoo: Yahoo is an openid provider. Talk to Yahoo endpoints. (Endpoint: http://yahoo.com)
  • Google: Google is a provider. Talk to them. (Endpoint: https://www.google.com/accounts/o8/id)
  • Facebook: Facebook connect provides authentication framework.
  • Twitter: We use Twitter Oauth for authentication. In theory, Oauth shouldn't be used for authentication. (It is an autorisation framework, not an authentication one), In practice it works pretty well. Once you have an access_token, and a name, essentially authenticated.
  • Github:We use Github Oauth for authentication. As like Twitter, it works pretty well.
  • Foursquare:We use Oauth2.0 for authenticating via foursquare.

References

  1. http://openid.net/developers/
  2. http://developer.yahoo.com/openid/
  3. http://code.google.com/apis/accounts/docs/OpenID.html
  4. http://apiwiki.twitter.com/OAuth-FAQ
  5. http://developers.facebook.com/connect.php
  6. http://develop.github.com/p/oauth.html
  7. https://developer.foursquare.com/overview/auth.html

Limitations

As with all APIs, we are limited by the amount of data which the API provider provides us. For example, both Yahoo and Google provide extremely limited data about the autheticated subscriber. Twitter and Facebook provide a lot of details, but not the email. Different Openid providers are free to provide [different amounts of data](http://openid.net/specs/openid-simple-registration-extension-1_0.html).

How it works.

  1. For all providers(except Facebook) there are two urls and views. (start and done)
  2. Start sets up the required tokens, and redirects and hands off to the correct provider.
  3. Provider handles authentication on their ends, and hands off to Us, providing authorization tokens.
  4. In done, we check if the user with these details already exists, if yes, we log them in. Otherwise we create a new user, and log them in.

For all of these, we use standard django authenication system, with custom auth_backends, hence all existing views, and decorators as login_required will work as expected.

Urls

  • /login/ Login page. Has all the login options
  • /openid_login/ AND /openid_login/done/
  • /yahoo_login/ AND /yahoo_login/done/
  • /gmail_login/ AND /gmail_login/done/
  • /twitter_login/ AND /twitter_login/done/
  • /facebook_login/done/ We dont have a start url here, as the starting tokens are set in a popup.
  • /github_login/ AND /github_login/done/
  • /foursquare_login/ AND /foursquare_login/done/

Implementation

  1. Install required libraries.
  2. Get tokens and populate in localsettings.py
  3. Set the token callback urls correctly at Twitter, Facebook, Github and Foursquare.
  4. Set the authentication_backends to the providers you are using.

django-socialauth's People

Contributors

akshar-raaj avatar ashok-raavi avatar cyrildoussin avatar daonb avatar drano avatar hoamon avatar lprsd avatar odifyltsaeb avatar paulswartz avatar phuihock avatar rochacon avatar shabda avatar sirex avatar stryderjzw avatar theju avatar tuxcanfly avatar twidi avatar vorushin avatar waynemoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-socialauth's Issues

KeyError when logging in with Twitter

I'm receiving the same errors as these issues:

The fix mentioned is to set a callback URL in the app's Twitter settings. I've set my callback URL, but I still receive the error. My app has been in production for about 6 months without any login issues, and now this issue has surfaced in the past two weeks. Did Twitter change the OAuth flow?

Here's my traceback:

Environment:

Request Method: GET
Request URL: http://thematic.me/accounts/twitter_login/
Django Version: 1.2.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'debug_toolbar',
'middleware',
'base',
'theme',
'invitation',
'tests',
'socialauth',
'reports',
'south',
'support',
'comments',,
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'middleware.swfupload.SWFUploadMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'subdomains.middleware.SubdomainURLRoutingMiddleware')

Traceback:
File "/home/chr15/webapps/thematic_prod/lib/python2.6/django/core/handlers/base.py" in get_response

  1.                 response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/chr15/webapps/thematic_prod/proj/genoa/socialauth/views.py" in twitter_login
  2. request_token = twitter.fetch_request_token(callback=request.build_absolute_uri(reverse('socialauth_twitter_login_done')))
    
    File "/home/chr15/webapps/thematic_prod/proj/genoa/socialauth/lib/oauthtwitter2.py" in fetch_request_token
  3.     return oauth.OAuthToken.from_string(oauth_response(oauth_request))
    
    File "build/bdist.linux-i686/egg/oauth/oauth.py" in from_string
  4.     key = params['oauth_token'][0]
    

Exception Type: KeyError at /accounts/twitter_login/
Exception Value: 'oauth_token'

double emails in user table

Socialauth does not check if user with this email already exists in user table. This might not be a problem, but i feel that there should be just one user with one email and all other social network connections should exist as a way to authenticate user, not create another user.

What i aim to achieve in near future is to create just one user when user registers(or logs in via socialauth), is to create one user and several means to authenticate this single user. Meaning that user could log in via facebook today and via gmail next day, if he has added different means of logging in earlier.

KeyError 'oauth_token' when logging in to Twitter

The error occurs for both Twitter and Linkedin. Everything else is works fine.

Traceback:

Environment:

Request Method: GET
Request URL: http://www.mydomain.com/accounts/twitter_login/?next=/
Django Version: 1.2.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.comments',
'socialauth',
'openid_consumer',
'commentor',
'example',
'example_comments']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'openid_consumer.middleware.OpenIDMiddleware',
'django.middleware.csrf.CsrfViewMiddleware')

Traceback:
File "/home/ubuntu/env/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
100.> > > > > response = callback(request, _callback_args, *_callback_kwargs)
File "/home/ubuntu/env/lib/python2.6/site-packages/django_socialauth-0.1.2c-py2.6.egg/socialauth/views.py" in twitter_login
90.> request_token = twitter.fetch_request_token(callback=request.build_absolute_uri(reverse('socialauth_twitter_login_done')))
File "/home/ubuntu/env/lib/python2.6/site-packages/django_socialauth-0.1.2c-py2.6.egg/socialauth/lib/oauthtwitter2.py" in fetch_request_token
46.> > return oauth.OAuthToken.from_string(oauth_response(oauth_request))
File "/home/ubuntu/env/lib/python2.6/site-packages/oauth/oauth.py" in from_string
142.> > key = params['oauth_token'][0]

Exception Type: KeyError at /accounts/twitter_login/
Exception Value: 'oauth_token'

Problem with external openid provider

I'm trying to connect with AppDirect-openid ( www.appdirect.com ) and I'm facing that issue:

provider url : https://www.appdirect.com/AppDirect/openid/id
provider documentation : https://www.appdirect.com/AppDirect/openid/op

Socialauth issue :
Generated checkid_setup request to https://www.appdirect.com/AppDirect/openid/op with assocication a68180c5cbcfaa3d
[16/Dec/2010 21:34:11] "GET /accounts/openid/?action=verify&openid_next=&openid_identifier=https%3A%2F%2Fwww.appdirect.com%2FAppDirect%2Fopenid%2Fid HTTP/1.1" 302 0
Error attempting to use stored discovery information: <openid.consumer.consumer.TypeURIMismatch: Required type http://specs.openid.net/auth/2.0/signon not found in ['http://specs.openid.net/auth/2.0/server', 'http://openid.net/srv/ax/1.0', 'http://openid.net/sreg/1.0', 'http://openid.net/extensions/sreg/1.1'] for endpoint <openid.consumer.discover.OpenIDServiceEndpoint server_url='https://www.appdirect.com/AppDirect/openid/op' claimed_id=None local_id=None canonicalID=None used_yadis=True >>
Attempting discovery to verify endpoint
Performing discovery on https://www.appdirect.com/AppDirect/openid/id/9807cf99-894f-4393-bb22-0d53e71fd1b8
Received id_res response from https://www.appdirect.com/AppDirect/openid/op using association 13cffc990062bdf7
Using OpenID check_authentication
op_endpoint
claimed_id
identity
return_to
response_nonce
assoc_handle
sreg.nickname
sreg.email
sreg.fullname
check_authentication failed: Malformed HTTP header line in response: ''
[16/Dec/2010 21:34:18] "GET /accounts/openid/complete/?janrain_nonce=2010-12-16T20%3A34%3A11Z4sgeHX&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.op_endpoint=https%3A%2F%2Fwww.appdirect.com%2FAppDirect%2Fopenid%2Fop&openid.claimed_id=https%3A%2F%2Fwww.appdirect.com%2FAppDirect%2Fopenid%2Fid%2F9807cf99-894f-4393-bb22-0d53e71fd1b8&openid.response_nonce=2010-12-16T20%3A34%3A15Z0&openid.mode=id_res&openid.identity=https%3A%2F%2Fwww.appdirect.com%2FAppDirect%2Fopenid%2Fid%2F9807cf99-894f-4393-bb22-0d53e71fd1b8&openid.return_to=http%3A%2F%2F192.168.104.209%3A8000%2Faccounts%2Fopenid%2Fcomplete%2F%3Fjanrain_nonce%3D2010-12-16T20%253A34%253A11Z4sgeHX&openid.invalidate_handle=a68180c5cbcfaa3d&openid.assoc_handle=13cffc990062bdf7&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Csreg.nickname%2Csreg.email%2Csreg.fullname&openid.sig=ig%2BEPpBDBaXsQB9dMCoqREfgLd9Ky%2BEib02Nr%2FX5Dfs%3D&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fsreg%2F1.0&openid.sreg.nickname=fabien%40revolunet.com&openid.sreg.email=fabien%40revolunet.com&openid.sreg.fullname=Fabien+xxxx&openid.ns.ext2=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext2.mode=fetch_response&openid.ext2.type.ext0=http%3A%2F%2Faxschema.org%2FnamePerson&openid.ext2.value.ext0=Fabien+xxxx&openid.ext2.type.ext2=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext2.value.ext2=fabien%40revolunet.com HTTP/1.1" 200 1168

It's well working with yahoo, gmail.

GPL V3 Licensing

Are you guys certain about your GPL V3 licensing change? This is huge because it means you can't use it in proprietary applications, which is pretty much every Django app.

If I'm developing a custom web app that's using this, I have to release all the source because of the copyleft nature of the license, even if I'm using this in a library-style capacity.

Can we see a change to LGPL? If not, I will have to move on to another package.

Facebook auth backend is failing because null data about the user is being returned by Facebook

Hello!

I hope you can help with this. I spent quite a bit of time last night trying to track this issue down to no avail. I've gone to Facebook, registered a new application, and added the appropriate data to the settings file. I set the Facebook connect URL to a development address that's defined in my hosts file and not accessible to the outside world. When I launch the server, browse to the login page and click the Facebook button, the Facebook popup comes up, I allow it access and then I'm taken to the Facebook done view which promptly fails with the following traceback:

Environment:

Request Method: GET
Request URL: http://myfancyapp.dev:8000/accounts/facebook_login/
Django Version: 1.2 pre-alpha SVN-11600
Python Version: 2.6.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'socialauth',
 'openid_consumer',
 'commentor']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'openid_consumer.middleware.OpenIDMiddleware')


Traceback:
File "/Users/twelfley/Library/Python/user-packages/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/Users/twelfley/Sites/Django-Socialauth/socialauth/views.py" in facebook_login_done
  148.             user = authenticate(cookies=request.COOKIES)
File "/Users/twelfley/Library/Python/user-packages/django/contrib/auth/__init__.py" in authenticate
  37.             user = backend.authenticate(**credentials)
File "/Users/twelfley/Sites/Django-Socialauth/socialauth/auth_backends.py" in authenticate
  141.                     name_count = User.objects.filter(username__istartswith = username).count()
File "/Users/twelfley/Library/Python/user-packages/django/db/models/manager.py" in filter
  129.         return self.get_query_set().filter(*args, **kwargs)
File "/Users/twelfley/Library/Python/user-packages/django/db/models/query.py" in filter
  498.         return self._filter_or_exclude(False, *args, **kwargs)
File "/Users/twelfley/Library/Python/user-packages/django/db/models/query.py" in _filter_or_exclude
  516.             clone.query.add_q(Q(*args, **kwargs))
File "/Users/twelfley/Library/Python/user-packages/django/db/models/sql/query.py" in add_q
  1675.                             can_reuse=used_aliases)
File "/Users/twelfley/Library/Python/user-packages/django/db/models/sql/query.py" in add_filter
  1539.                 raise ValueError("Cannot use None as a query value")

Exception Type: ValueError at /accounts/facebook_login/
Exception Value: Cannot use None as a query value

From what I can tell, socialauth/auth_backends.py is failing on line 141 because of lines 134 and 135:
user_info_response = get_user_info(API_KEY, API_SECRET, cookies)
username = user_info_response[0]['first_name']

Line 134 sets user_info_response to [{'first_name': None, 'last_name': None, 'uid': 5112589, 'pic_small': None, 'current_location': None, 'name': None}] and subsequently, line 135 sets username to None. I'm assuming this means that something having to do with authorization is failing silently somewhere along the way, but I just can't find where or why.

Here are the values for some other things that may or may not be relevant to debugging this:
cookies = {'662a83d2d3cc91f33ee497e4c4fcbba3': '97d6bfa461ee14110d66efc2615efab6', '662a83d2d3cc91f33ee497e4c4fcbba3_expires': '1258538400', '662a83d2d3cc91f33ee497e4c4fcbba3_ss': 'dm43yXNww_uzTFad4Q7oNQ__', '662a83d2d3cc91f33ee497e4c4fcbba3_user': '5112589', '662a83d2d3cc91f33ee497e4c4fcbba3_session_key': '3.LIcaksSdXfEPikRaonAQFw__.86400.1258538400-5112589'}
signature_hash = 97d6bfa461ee14110d66efc2615efab6

When I go to Facebook and look at my installed/authorized applications, I see the app I registered listed under "External Websites". So, that part seems to be working at least.

Any thoughts?

wrong user data from google

when logging in via google, user.username and user.email are set incorrectly.
for example i logged in the demo site, and the title is Hello rwuuavcmvn (and by checking users db on my own machine i see that also email is set incorrectly).
with facebook and twitter it works ok (user name is facebook_myusername and twitter_myusername).

401 on twitter login twitter.fetch_access_token

I made an twitter app, and used
callback url: http://127.0.0.1/accounts/twitter_login/done/
and used my keys from twitter

i can click 127.0.0.1:"login via twitter" -> twitter:"Allow testapp access? Allow" -> redirect back to 127.0.0.1 with the following error:

HTTPError at /accounts/twitter_login/done/

HTTP Error 401: Unauthorized

Request Method: GET
Request URL: http://127.0.0.1/accounts/twitter_login/done/?oauth_token=BkcU0Z4XF0uEM8Lmw2GNNt7rKd26sFqlGO3dg6lvdu8
Exception Type: HTTPError
Exception Value:

HTTP Error 401: Unauthorized

Exception Location: /usr/lib/python2.5/urllib2.py in http_error_default, line 506

Environment:

Request Method: GET
Request URL: http://127.0.0.1/accounts/twitter_login/done/?oauth_token=tLXtEb2uLliaQWOnOPct0rW0uXEsEDfWmJKWJooiTCA
Django Version: 1.2 pre-alpha
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'socialauth',
'openid_consumer',
'commentor']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'openid_consumer.middleware.OpenIDMiddleware')

Traceback:
File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response

  1.             response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/tim/projects/django-socialauth/socialauthdemo/socialauth/views.py" in twitter_login_done
  2. access_token = twitter.fetch_access_token(token)
    
    File "/home/tim/projects/django-socialauth/socialauthdemo/socialauth/lib/oauthtwitter2.py" in fetch_access_token
  3.     response = urllib2.urlopen(full_url)
    
    File "/usr/lib/python2.5/urllib2.py" in urlopen
  4. return _opener.open(url, data)
    
    File "/usr/lib/python2.5/urllib2.py" in open
  5.         response = meth(req, response)
    
    File "/usr/lib/python2.5/urllib2.py" in http_response
  6.             'http', request, response, code, msg, hdrs)
    
    File "/usr/lib/python2.5/urllib2.py" in error
  7.         return self._call_chain(*args)
    
    File "/usr/lib/python2.5/urllib2.py" in _call_chain
  8.         result = func(*args)
    
    File "/usr/lib/python2.5/urllib2.py" in http_error_default
  9.     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    

Exception Type: HTTPError at /accounts/twitter_login/done/
Exception Value: HTTP Error 401: Unauthorized

I print the "full_url" called on line 54 and get this.

https://twitter.com/oauth/access_token?oauth_nonce=42143232&oauth_timestamp=1251568312&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=CdOETLhqWp3bImdIZh5dw&oauth_verifier=None&oauth_version=1.0&oauth_token=BkcU0Z4XF0uEM8Lmw2GNNt7rKd26sFqlGO3dg6lvdu8&oauth_signature=e67zk3WzNw9zBAvxOYDIzblN2so%3D&oauth_callback=None

any ideas?

Logging in with Yahoo and Google returns "certificate verify failed"

I've just downloaded your demo code, ran it and found some problem with Yahoo and Google sign in.

Yahoo:
Receive 500 error

HTTPFetchingError at /accounts/yahoo_login/complete/
(60, 'SSL certificate problem, verify that the CA cert is OK. Details:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed')

Google:
OpenID failed:
The OpenID was invalid
(but if you really debug into it, you'd see the same error as Yahoo in DiscoveryFailure exception

Do you know why this would happen?

Thank you.

'User' object has no attribute 'authmeta'

when trying to edit the user info in /accounts/edit/profile/ i get :
'User' object has no attribute 'authmeta'
for
authmeta = user.authmeta
/home/vinivici/modules/django_socialauth-0.1.2c-py2.6.egg/socialauth/forms.py in save line 54

Incorrect statements about Google in README

It is staded in README that "Google provide extremely limited data
about the autheticated subscriber". But it is not true. The fact is that Google doesn't support sreg extension because it supports newer ax extension. All the data about user is provided through ax.

nonexistent models being loaded in admin.py

For those of using the free admin site, Django throws a one-off 500 on encountering this line in admin.py:

from socialauth.models import GmailContact, YahooContact, TwitterContact,
FacebookContact, SocialProfile

These erroneous imports / registers should be removed :-)

python-openauth

In the README it says to easy_install this library: python-openauth,
but I get an error:
...
Reading http://pypi.python.org/simple/
No local packages or download links found for python-openauth
error: Could not find suitable distribution for Requirement.parse('python-openauth')

setup.py

"socialauth.lib" is missing from packages in setup.py

and the pypi version is not up to date.

Breaks CSRF middleware in Django 1.2

Django-Socialauth breaks when using CsrfViewMiddleware in Django 1.2. This can be fixed with 3 modifications:

    diff --git a/openid_consumer/templates/openid_consumer/signin.html b/openid_consumer/templates/openid_consumer/signin.html
    index b378ee2..601db02 100644
    --- a/openid_consumer/templates/openid_consumer/signin.html
    +++ b/openid_consumer/templates/openid_consumer/signin.html
    @@ -11,7 +11,7 @@

     <h1>{% trans "Sign in with your OpenID" %}</h1>

    -<form action="{{ action }}" method="post">
    +<form action="{{ action }}" method="post">{% csrf_token %}
     <p><input class="openid" type="text" name="openid_url"> <input type="submit" value="{% trans "Sign in" %}"></p>
     </form>

    @@ -31,4 +31,4 @@
     <body>
     </body>
     </html>
    -#}
    \ No newline at end of file
    +#}
    diff --git a/openid_consumer/views.py b/openid_consumer/views.py
    index a762275..6bba504 100644
    --- a/openid_consumer/views.py
    +++ b/openid_consumer/views.py
    @@ -87,7 +87,7 @@ def begin(request, redirect_to=None, on_failure=None, user_url=None, template_na

             return render(template_name, {
                 'action': request_path,
    -        })
    +        }, context_instance=RequestContext(request))

         if xri.identifierScheme(user_url) == 'XRI' and getattr(
             settings, 'OPENID_DISALLOW_INAMES', False
    diff --git a/socialauth/templates/socialauth/editprofile.html b/socialauth/templates/socialauth/editprofile.html
    index b6fae59..580debd 100644
    --- a/socialauth/templates/socialauth/editprofile.html
    +++ b/socialauth/templates/socialauth/editprofile.html
    @@ -5,7 +5,7 @@

     {% block content %}

    -<form action="." method="post">
    +<form action="." method="post">{% csrf_token %}
         <table>
         {{ edit_form }}
         </table>
    @@ -13,4 +13,4 @@
     </form>


    -{% endblock %}
    \ No newline at end of file
    +{% endblock %}

urls.py broken

Looks like part of a patch got inserted into urls.py mistakenly

Installation instructions

Hi there,

I'm trying to setup this Django app in my project and it's getting on my nerves.

The README is missing a lot of information on how to do this. Things like the names of the token variables in settings.py, what to add to INSTALLED_APPS, add urls.py to urlpatterns, if it is necessary to set up a middleware or a context processor and in what cases and I guess that much more as I haven't managed to make it completely work.

To sum up I think documentation could be improved a lot.

Thanks, regards
Miguel Araujo

OpenID AuthBackend - Don't use str.format() method.

Hi. I'm deploying a project with socialauth, and deploying it in a server with Python 2.5.
The problem is that with Python versions under 2.6 the str.format() method isn't available and the OpenID login just won't work because of it.

The fix that I found was to replace all str.format() entries (total of 4 in the auth_backends.py) to the "old style string formatters" (e.g "%s" % (username)).

Everything works fine now.

Thanks for this great app and keep up the great work !

twitter auth works once then errors

Basically, click 'twitter', 'allow', 'sign out', 'twitter' -> error -> (either BadStatusLine or CannotSend - both pasted below)

BadStatusLine at /accounts/twitter_login/
Request Method: GET
Request URL: http:///accounts/twitter_login/?next=/
Django Version: 1.2.3
Exception Type: BadStatusLine
Exception Value:
Exception Location: /usr/lib/python2.6/httplib.py in _read_status, line 355
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path: ['/usr/local/lib/python2.6/dist-packages/oauth-1.0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/oauth_python_twitter-1.0-py2.6.egg', '/usr/lib/pymodules/python2.6', '/usr/local/lib/python2.6/dist-packages/oauth2-1.5.168-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_socialregistration-0.4.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pip-1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_socialauth-0.1.2c-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/var', '/usr/lib/python-django', '/var/www//djcode', '/var/www//djcode/']
Server time: Sat, 16 Apr 2011 05:26:36 -0500

Django Version: 1.2.3
Exception Type: CannotSendRequest
Exception Value:
Exception Location: /usr/lib/python2.6/httplib.py in putrequest, line 818
Python Executable: /usr/bin/python
Python Version: 2.6.6

Add authors

Add authors file for socialauth.

Include All people whose forks have been merged.

Auth_backends

auth_backends.py needs a 'return user' around line 50

confusing licence statement / dual licence

Sure, a licence expert (which simply 9 out of 10 users/developers are not) might figure out we're talking BSD/GPL conform licence here http://github.com/uswaretech/Django-Socialauth/commit/ea105bb6b2cfaab8a9a1134fe350fe920bf1b7b5

The other 9 are probably confused or even worse, scared away ... I'd recommend using one licence and explicitely state so. GPLv3 for example. Then put the standard Licence Text into the LICENCE file ... happy users, happy developers. Happy growing django-socialauth.

Problem with facebook logout

I have added this piece of code to login_page to make the login/logout more natural

  document.cookie = "fbs_{{ FACEBOOK_APP_ID }}=; expires=Thu, 01-Jan-70 00:00:01 GMT;path=/;domain=.mines.com";
  FB.init({appId: '{{ FACEBOOK_APP_ID }}', status: true, cookie: true, xfbml: true});
  FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
  $("#facebook").click(function() {
    window.location = '{% url socialauth_facebook_login_done %}';
  });
}
  });

Problems with Facebook store using Postgres

The facebookuid is defined as:
facebook_uid = models.CharField(max_length = 20, unique = True)

which causes an error when the facebook profile is stored (since it is an integer)
operator does not exist: character varying = integer
LINE 1: ...E "socialauth_facebookuserprofile"."facebook_uid" = 70212030..

I fixed it by changing line 137 in auth_backends.py from:
profile = FacebookUserProfile.objects.get(facebook_uid = user_info_response[0]['uid'])
to
profile = FacebookUserProfile.objects.get(facebook_uid = str(user_info_response[0]['uid']))

same name count in auth_backends.py leads to issues in some cases

I was tracking down a bug for more than a few hours and it came down to this. Basically I had a registered username of ben86lee2 in my app, and when I tried to register another account where the screen_name was ben86lee, the following code said there was already 1 user whose username started with "ben86lee". So it then tried to register ben86lee as ben86lee2 because of the "+1" step in the code below. But there already is a ben86lee2, so it finally gave an integrity error. So basically maybe the code could be changed to not use __startswith and just do exact matches instead. Or any other solution that would avoid this issue. Basically this error would occur anytime a username of "abc2" is registered but "abc" is not. Of course switch out "abc" with any username and the same error would occur.

same_name_count = (User.objects
                               .filter(username__startswith=screen_name)
                               .count())
if name_count:
            username = '%s%d' % (nickname, name_count + 1)

suggesting something like:

same_name_count = (User.objects
                               .filter(username=screen_name)
                               .count())
 if name_count:
            username = '%s%d' % (nickname, name_count + 1)

Thanks for your time and effort on this great open source package.

app should use setup.py install

There's no installation method for the apps.

Currently to get the application working in an existing project, I'm symlinking the openid_consumer and socialauth apps from my project directory and pointing them towards the demo folder. so hopefully when the source gets updated i can just git pull into your project dir and it won't hurt my app.

AttributeError at /accounts/facebook_login/done/

Any ideas why I'm getting this?

'module' object has no attribute 'get_user_from_cookie'
Request Method: GET
Request URL:    /accounts/facebook_login/done/
Django Version: 1.3.1
Exception Type: AttributeError
Exception Value:  
'module' object has no attribute 'get_user_from_cookie'
Exception Location: /var/www/wsgi/myproject/socialauth/auth_backends.py in authenticate, line 264
Python Executable:  /usr/bin/python
Python Version: 2.6.5
Python Path:  
['/var/www/wsgi',
 '/var/www/wsgi/myproject/socialauth/lib/',
 '/var/www/wsgi/myproject/',
 '/var/www/wsgi/myproject/myapp/',
 '/usr/local/lib/python2.6/dist-packages/django_socialauth-0.1.2c-py2.6.egg',
 '/home/ubuntu/src/facebook-python-sdk/src',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/dist-packages',
 '/usr/lib/pymodules/python2.6',
 '/usr/lib/pymodules/python2.6/gtk-2.0',
 '/usr/local/lib/python2.6/dist-packages']

while:

Cheetah==2.0.1
Django==1.3.1
GnuPGInterface==0.3.2
Landscape-Client==11.07.1.1
M2Crypto==0.20.1
MySQL-python==1.2.2
PAM==0.4.2
PyYAML==3.09
Twisted-Core==10.0.0
Twisted-Web==10.0.0
boto==1.9b
cloud-init==0.5.10
command-not-found==0.1
configobj==4.7.1
distribute==0.6.10
django-social-auth==0.6.0
django-socialauth==0.1.2c
euca2ools==1.2
facebook-python-sdk==0.1
httplib2==0.6.0
launchpadlib==1.6.0
lazr.restfulclient==0.9.11
lazr.uri==1.0.2
mod-python==3.3.1
oauth==1.0a
oauth2==1.5.211
pexpect==2.3
pyOpenSSL==0.10
pycurl==7.19.0
pyserial==2.3
python-apt==0.7.94.2ubuntu6.4
python-openid==2.2.5
simplejson==2.0.9
smart==1.2
ufw==0.30pre1-0ubuntu2
unattended-upgrades==0.1
wadllib==1.1.4
wsgiref==0.1.2
zope.interface==3.5.3

Facebook Connect oAuth 'Error validating verification code.' Error

Having some trouble with facebook connect. I would click the button and attempt to login, nothing would happen.

Finally I added a pdb statement inside of authenticate in FacebookBackend and got this json response from Facebook:

'{"error":{"type":"OAuthException","message":"Error validating verification code."}}'

I've tried various post authorize urls. Currently, my base url for socialauth is socauth The urls I've tried are:

  1. http://ip/socauth/
  2. http://ip/socauth/facebook_login/
  3. http://ip/socauth/facebook_login/done/

None of these work.

As a side note: it'd be nice if the documentation mentioned what you should set the post authorize callback url (on the Facebook side) to.

socialauth_facebook_login "next" url to include host name (patch included)

When using the "'socialauth_facebook_login" view to login to Facebook, the user is redirected to a wrong URL after a successful login. The reason is that the URL to redirect to ("next") is based on a Django URL reversal, resulting in an URL path only. Hence, you are redirected to an URL of the form http://www.facebook.com/{django-eversed-url-path}, which clearly does not exist.

See patch below:

--- Django-Socialauth/socialauth/views.py
+++ Django-Socialauth/socialauth/views.py
@@ -203,7 +203,7 @@
params = {}
params["api_key"] = settings.FACEBOOK_API_KEY
params["v"] = "1.0"

  • params["next"] = reverse("socialauth_facebook_login_done")[1:] # remove leading slash
  • params["next"] = 'http://%s%s' % (request.get_host(), reverse("socialauth_facebook_login_done"))
    params["canvas"] = "0"
    params["fbconnect"] = "1"

Cancel link must be a full URL

ImportError at /accounts/login/ No module named pape

in bash:
$ cd ~/projects/

$ mkdir django-socialauth

$ cd django-socialauth

$ virtualenv sa

$ source sa/bin/activate

$ git clone git://github.com/uswaretech/Django-Socialauth.git

$ mv Django-Socialauth socialauthdemo

$ cd sa/lib/python2.5/site-packages/

$ svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk

$ cd django-trunk/

$ python setup.py install

$ cd ~/projects/socialauthdemo/

$ easy_install python_openid
Installed /home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/python_openid-2.2.4-py2.5.egg

$ easy_install python-yadis
Adding python-yadis 1.1.0 to easy-install.pth file

easy_install python-oauth <- doesnt exist

easy_install python_oauth <- doesnt exist

cd sa/lib/python2.5/site-packages/

wget http://oauth.googlecode.com/svn/code/python/oauth/oauth.py

$ cd ~/projects/socialauthdemo/

python manage.py syncdb

python manage.py runserver

in firefox: http://localhost:8000/accounts/login/?next=/

Environment:
ImportError at /accounts/login/

No module named pape

Request Method: GET
Request URL: http://localhost:8000/accounts/login/?next=/
Exception Type: ImportError
Exception Value:

No module named pape

Exception Location: /home/tim/projects/django-socialauth/socialauthdemo/openid_consumer/views.py in , line 16
Python Executable: /home/tim/projects/django-socialauth/sa/bin/python
Python Version: 2.5.4

Request Method: GET
Request URL: http://localhost:8000/accounts/login/?next=/
Django Version: 1.2 pre-alpha
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'socialauth',
'openid_consumer',
'commentor']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'openid_consumer.middleware.OpenIDMiddleware')

Traceback:
File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response

  1.                 request.path_info)
    
    File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
  2.                 sub_match = pattern.resolve(new_path)
    
    File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
  3.         for pattern in self.url_patterns:
    
    File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_url_patterns
  4.     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    
    File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
  5.         self._urlconf_module = import_module(self.urlconf_name)
    
    File "/home/tim/projects/django-socialauth/sa/lib/python2.5/site-packages/django/utils/importlib.py" in import_module
  6. **import**(name)
    
    File "/home/tim/projects/django-socialauth/socialauthdemo/socialauth/urls.py" in
  7. from openid_consumer.views import begin, complete, signout
    File "/home/tim/projects/django-socialauth/socialauthdemo/openid_consumer/views.py" in
  8. from openid.extensions.pape import Request as PapeRequest
    

Exception Type: ImportError at /accounts/login/
Exception Value: No module named pape

openid_consumer: DjangoOpenIDStore stores invalid lifetime

It actually assigns the time issued to the lifetime field, see patch below:

--- util.py.orig 2010-02-09 09:04:40.000000000 +0100
+++ util.py 2010-02-10 13:42:28.000000000 +0100
@@ -46,7 +46,7 @@
handle = association.handle,
secret = base64.encodestring(association.secret),
issued = association.issued,

  •        lifetime = association.issued,
    
  •        lifetime = association.lifetime,
         assoc_type = association.assoc_type
     )
     assoc.save()
    

Datetime issue with facebook

Under the socialauth/views.py and socialauth/auth_backends.py you check for this condition:
(datetime.fromtimestamp(float(cookies[API_KEY+'_expires'])) > datetime.now())
If I am a returning user and the app that I am using requires offline_access then a permanent session token is assigned to that user. If a user has a permanent session token the datetime for the above condition will always fail. If its not a permanent session, perhaps you could check for the existence of uid on whether or not the session is still valid?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.