Django WeChat OAuth2/Share/Token API
Project description
django-we
Django WeChat OAuth2/Share/Token API
Installation
pip install django-we
Urls.py
from django.urls import include, re_path
urlpatterns = [
re_path(r'^we/', include('django_we.urls', namespace='django_we')),
]
or
from django.urls import re_path
from django_we import views as we_views
# WeChat OAuth2
urlpatterns = [
re_path(r'^o$', we_views.we_oauth2, name='shorten_o'),
re_path(r'^oauth$', we_views.we_oauth2, name='shorten_oauth'),
re_path(r'^oauth2$', we_views.we_oauth2, name='shorten_oauth2'),
re_path(r'^we_oauth2$', we_views.we_oauth2, name='we_oauth2'),
re_path(r'^base_redirect$', we_views.base_redirect, name='base_redirect'),
re_path(r'^userinfo_redirect$', we_views.userinfo_redirect, name='userinfo_redirect'),
re_path(r'^direct_base_redirect$', we_views.direct_base_redirect, name='direct_base_redirect'),
re_path(r'^direct_userinfo_redirect$', we_views.direct_userinfo_redirect, name='direct_userinfo_redirect'),
]
# WeChat Share
urlpatterns += [
re_path(r'^ws$', we_views.we_share, name='shorten_we_share'),
re_path(r'^weshare$', we_views.we_share, name='we_share'),
]
# WeChat JSAPI Signature
urlpatterns += [
re_path(r'^js$', we_views.we_jsapi_signature_api, name='shorten_we_jsapi_signature_api'),
re_path(r'^jsapi_signature$', we_views.we_jsapi_signature_api, name='we_jsapi_signature_api'),
]
# WeChat Token
urlpatterns += [
re_path(r'^token$', we_views.we_access_token, name='we_token'),
re_path(r'^access_token$', we_views.we_access_token, name='we_access_token'),
]
Settings.py
INSTALLED_APPS = (
...
'django_we',
...
)
# Wechat Settings
WECHAT = {
'JSAPI': {
'token': '5201314',
'appID': '',
'appsecret': '',
'mchID': '',
'apiKey': '',
'mch_cert': '',
'mch_key': '',
'redpack': {
'SEND_NAME': '',
'NICK_NAME': '',
'ACT_NAME': '',
'WISHING': '',
'REMARK': '',
}
},
}
# Wechat OAuth Cfg
DJANGO_WE_OAUTH_CFG = 'JSAPI' # Default ``JSAPI``
# Based on Urls.py
# WECHAT_OAUTH2_REDIRECT_URI = 'https://we.com/we/we_oauth2?scope={}&redirect_url={}'
# WECHAT_OAUTH2_REDIRECT_URI = 'https://we.com/we/o?scope={}&r={}' # Shorten URL
WECHAT_OAUTH2_REDIRECT_URI = 'https://we.com/we/o?r={}' # Shorten URL Farther, Scope default ``snsapi_userinfo``
WECHAT_BASE_REDIRECT_URI = 'https://we.com/we/base_redirect'
WECHAT_USERINFO_REDIRECT_URI = 'https://we.com/we/userinfo_redirect'
WECHAT_DIRECT_BASE_REDIRECT_URI = 'https://we.com/we/direct_base_redirect'
WECHAT_DIRECT_USERINFO_REDIRECT_URI = 'https://we.com/we/direct_userinfo_redirect'
# Temp Share Page to Redirect
WECHAT_OAUTH2_REDIRECT_URL = ''
Callbacks
Wechat_Only
- Settings.py
MIDDLEWARE = [ ... 'detect.middleware.UserAgentDetectionMiddleware', ... ] WECHAT_ONLY = True # Default False
- Usage
from django_we.decorators import wechat_only @wechat_only def xxx(request): """ Docstring """
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
django-we-1.5.9.tar.gz
(12.4 kB
view details)
Built Distribution
File details
Details for the file django-we-1.5.9.tar.gz
.
File metadata
- Download URL: django-we-1.5.9.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88e82ae81d475c0137dc82a0285c4fead4abf1bae135011a9169748951ed2224 |
|
MD5 | c92d9989c6618060ba89e5e09568642d |
|
BLAKE2b-256 | 7acc310a78acad7abb859363e76bbcd7b0fb86cd683e21588494650b9d1ff636 |
File details
Details for the file django_we-1.5.9-py2.py3-none-any.whl
.
File metadata
- Download URL: django_we-1.5.9-py2.py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3c70ababc47e28638c89d16695195e475b9d605e0f421b926d32c7f837a36f3 |
|
MD5 | 95350f16bf94cef22bd24e1aa57f5b4b |
|
BLAKE2b-256 | 2ed7246c2e5cccb2b7d48da2db18718e44601514c7aba26151487c80e84a8926 |