Coder Social home page Coder Social logo

django-slack-oauth's Introduction

Django Slack OAuth

Django module for handling Slack OAuth. In order to use Slack OAuth in your project you need to create application https://api.slack.com/applications Users must be authenticated on your site.

Install

pip install django-slack-oauth

Set up

  1. Add django_slack_oauth to your INSTALLED_APPS settings:
INSTALLED_APPS = (
    ...
    'django_slack_oauth',
)
  1. Run ./manage migrate; South or Django>=1.7 is required.
  2. Include the application URLconf in your project urls.py:

url(r'^slack/', include('django_slack_oauth.urls')),

4.1 Set up in your settings, these are required:

SLACK_CLIENT_ID = os.environ.get('SLACK_CLIENT_ID')
SLACK_CLIENT_SECRET = os.environ.get('SLACK_CLIENT_SECRET')

# Optional parameters
# Defaults
SLACK_SCOPE = 'identify,read,post'
SLACK_SUCCESS_REDIRECT_URL = '/'
SLACK_TEAM = ''

# These are in case slack team decides
# to change it's endpoints
SLACK_AUTHORIZATION_URL = 'https://slack.com/oauth/authorize'
SLACK_OAUTH_ACCESS_URL = 'https://slack.com/api/oauth.access'

With optional settings you could provide custom scope or redirect url upon completion

4.2 To avoid forgery attacks we pass state param in authorization request on slack endpoint. This state is stored in cache. For production environments I'd highly recommend to set up your cache backend using Redis or memcached other than LocMemCache. Example:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}
  1. Use the url to authenticate your users in your templates

<a href='{% url 'slack_auth' %}'>Get slacked</a>

  1. Find your token in slack_user table

django-slack-oauth's People

Contributors

izdi avatar brendanwood avatar avelis avatar theotheo avatar

Watchers

James Cloos avatar  avatar  avatar

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.