I use the Python/Django write the backend, use Django-Rest-Framework write the APIs, I also used the rest_auth
, allauth
, see my settings.py
:
INSTALLED_APPS = [
...
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_docs', # API docs
'rest_auth',
'allauth',
'allauth.account',
but when the frontend access the APIs, it will must add the Authorization
in the
Request Header, otherwise can not access success:
as a example:
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.
}
)