Skip to main content

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.

Source Distribution

django-socialnetwork-0.0.6.tar.gz (12.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page