Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Provides functionality to login and share with social networks to Django.

Project description

django-socialnetwork

This packages provides login and share funcionalities for the social networks.

Installation

pip install django-socialnetwork

Basic usage

  1. Add socialnetwork to INSTALLED_APPS.
INSTALLED_APPS = (
    ...
    ...
    'socialnetwork',
    'socialnetwork.facebook',
    ...
    ...
)
  1. Set your social app configuration in settings.
SOCIALNETWORK_FACEBOOK_CLIENT_ID = '0123456789'
SOCIALNETWORK_FACEBOOK_CLIENT_SECRET = '0123456789abcdefgh'
SOCIALNETWORK_FACEBOOK_SCOPE_PERMISSIONS = ['email', ...]
  1. Add the social backends to your AUTHENTICATION_BACKENDS.
AUTHENTICATION_BACKENDS = (
    ...
    ...
    'socialnetwork.facebook.backends.FacebookBackend',
    ...
    ...
)
  1. Add socialnetwork to your urls.
urlpatterns = patterns('',
    ...
    ...
    url(r'^social/', include('socialnetwork.urls', namespace='socialnetwork')),
    ...
    ...
)
  1. Show login button in your templates.
...
...
{% load facebook %}
...
...
{% facebook_login 'text to show in button' 'css_class1 css_class2 ... css_classN' %}
...
...
  1. Share content using tags in your templates (you can provide any named args accepted by the Facebook JavaScript SDK).
...
...
{% load facebook %}
...
...
{% facebook_share 'text to show in button' 'css_class1 css_class2 ... css_classN' link="mysite.com" name="This is my site" ... %}
...
...
  1. Request data. The client must be initialized with a profile object.
...
...
from socialnetwork.facebook.clients import FacebookGraph
...
...
graph = FacebookGraph(user.facebookoauthprofile)
data = graph.get('me', params={'fields': 'first_name,last_name,picture.type(normal)'})
data['first_name']
>>> 'John'
  1. Check access token.
graph.debug_access_token()
>>> (True, {'data': {'is_valid':True, 'access_token':...}})

TODO

  1. Provide a method to call a custom setup when the OAuth flow ends.
  2. Extend support for OAuth 2 services (Foursquare, Github, etc.)
  3. Add support for OAuth 1 services (Twitter, LinkedIn, etc.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-socialnetwork, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size django-socialnetwork-0.0.6.tar.gz (12.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page