【发布时间】:2018-03-15 08:14:35
【问题描述】:
我用Python/Django写后端,用Django-Rest-Framework写API,我也用rest_auth,allauth,看我的settings.py:
INSTALLED_APPS = [
...
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_docs', # API docs
'rest_auth',
'allauth',
'allauth.account',
但是当前端访问API时,它必须添加Authorization在
Request Header,否则无法访问成功:
例如:
var that = this
// login
that.$http.post(Urls.users.login(), params).then((response) => {
that.$Cookies.set('token', response.data.key);
}).catch((response) => { // if the header do not have `Authorization`, there will go to there directly, and pay attention: the response is undefined.
}
)
【问题讨论】:
标签: javascript python django-allauth django-rest-auth