Handles OAuth and stores slack token
Project description
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
Add django_slack_oauth to your INSTALLED_APPS settings:
INSTALLED_APPS = (
...
'django_slack_oauth',
)
Run ./manage migrate; Django>=1.8 is required.
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 = '/'
# 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',
}
}
Use the url to authenticate your users in your templates
<a href='{% url 'slack_auth' %}'>Get slacked</a>
Find your token in slack_user table
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_slack_oauth-0.6.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 806d40f3064c439e03989ab303beed32ed05a9252224671434df1da9765bff9f |
|
MD5 | 412cccd42d0afb1950636494fdec0d0a |
|
BLAKE2b-256 | 0404f924dc64384f922fba2065a90a681b64dc1d45befb75d3109088e714af67 |