在 django 应用程序中使用 TU 身份验证的简单方法。
项目描述
Dajgno TU 身份验证
=========================
要求
============
- python (2.7, 3.5)
- django ( 1.11, 2.0)
- social-app-django (2.1.0)
安装
============
```
pip install git+https://github.com/LeOntalEs/django-tuauth.git
```
用法
=====
### 先决条件
在 api.tu.ac.th/applications 中注册应用程序
> 注意:回调 URL 必须与 urls.py 中的 decarelation
> 在本例中使用 http://127.0。 0.1/oauth/complete/tu/
### in setting.py
```python
INSTALLED_APPS = [
...
'social_django',
'tuauth',
...
]
```
在setting.py 中添加身份验证后端
```python
AUTHENTICATION_BACKENDS = (
...
'tuauth.backend.TUOAuth2',
...
)
```
在setting.py 中设置客户端ID 和客户端密码
```python
SOCIAL_AUTH_TU_KEY = '<client_id>'
SOCIAL_AUTH_TU_SECRET = '<client_secret>'
```
SOCIAL_AUTH_PIPELINE 示例
```python
SOCIAL_AUTH_PIPELINE = [
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline .social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.user.create_user'、
'social_core.pipeline.social_auth.associate_user'、
'social_core.pipeline.social_auth.load_extra_data'、
'social_core.pipeline.user.user_details'、
'social_core.pipeline.social_auth.associate_by_email'、
]
``` > 在 (https://github.com/python-social-auth/social-app-django) ### in urls.py
中查看有关 **social-app-django** 的更多详细信息`` ` urlpatterns = [ ... path('oauth/', include('social_django.urls', namespace='social')), # in django2 ... ] ``` ### in template ``` .. . <a href="{% url 'social:begin' 'tu' %}">用 TU 登录</a><br>
...
```
=========================
要求
============
- python (2.7, 3.5)
- django ( 1.11, 2.0)
- social-app-django (2.1.0)
安装
============
```
pip install git+https://github.com/LeOntalEs/django-tuauth.git
```
用法
=====
### 先决条件
在 api.tu.ac.th/applications 中注册应用程序
> 注意:回调 URL 必须与 urls.py 中的 decarelation
> 在本例中使用 http://127.0。 0.1/oauth/complete/tu/
### in setting.py
```python
INSTALLED_APPS = [
...
'social_django',
'tuauth',
...
]
```
在setting.py 中添加身份验证后端
```python
AUTHENTICATION_BACKENDS = (
...
'tuauth.backend.TUOAuth2',
...
)
```
在setting.py 中设置客户端ID 和客户端密码
```python
SOCIAL_AUTH_TU_KEY = '<client_id>'
SOCIAL_AUTH_TU_SECRET = '<client_secret>'
```
SOCIAL_AUTH_PIPELINE 示例
```python
SOCIAL_AUTH_PIPELINE = [
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline .social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.user.create_user'、
'social_core.pipeline.social_auth.associate_user'、
'social_core.pipeline.social_auth.load_extra_data'、
'social_core.pipeline.user.user_details'、
'social_core.pipeline.social_auth.associate_by_email'、
]
``` > 在 (https://github.com/python-social-auth/social-app-django) ### in urls.py
中查看有关 **social-app-django** 的更多详细信息`` ` urlpatterns = [ ... path('oauth/', include('social_django.urls', namespace='social')), # in django2 ... ] ``` ### in template ``` .. . <a href="{% url 'social:begin' 'tu' %}">用 TU 登录</a><br>
...
```
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
django-tuauth-1.0.tar.gz
(3.5 kB
查看哈希)
内置分布
django_tuauth-1.0-py3-none-any.whl
(3.7 kB
查看哈希)
关
django_tuauth -1.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d73b05ce712143708139374153cfe63ea262fb669b459139d2e86a7965e84d66 |
|
MD5 | aa360a02c5c10a9ef310586718222554 |
|
布莱克2-256 | 2a13e87fbc6ec07b5e70650788eb105f6e93c1d0ad4f8e424166839dcdf7e0a8 |