Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login error, submit data error #16

Closed
ghost opened this issue May 21, 2016 · 2 comments
Closed

login error, submit data error #16

ghost opened this issue May 21, 2016 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented May 21, 2016

servers i used http://www.django-rest-framework.org/
the app login page demo in therehttp://restframework.herokuapp.com/api-auth/login/?next=/

i want use ng2-resource-rest login that

but, ng2-resource-rest submit data have question

i capture Chrome login data:
submit data is:csrfmiddlewaretoken=G71nGgFwhUyguxhdNz8c6DdWLHDKKr6K&username=111111111&password=112222222222222&next=%2F&submit=Log+in


i use ng2-resource-rest:
code :

 this.Res.login("csrfmiddlewaretoken=kgEviC68d6OAB23v5fZlu0e1GO5oig7c&next=&username=111111&password=222222&submit=Log+inName")
                .$observable
                .subscribe(
                  res => console.log(res),
                   err => console.log('Err', err)
               );

i capture Chrome login data:
"csrfmiddlewaretoken=kgEviC68d6OAB23v5fZlu0e1GO5oig7c&next=&username=111111&password=222222&submit=Log+inName"

have quotation marks


then i change i code:

      this.Res.login({username: '111111', password: '222222',csrfmiddlewaretoken:'kgEviC68d6OAB23v5fZlu0e1GO5oig7c',next:'/',submit:'Log+in'})
                .$observable
            .subscribe(
                res => console.log(res),
                err => console.log('Err', err)
            );

i capture Chrome login data:
{"username":"111111","password":"222222","csrfmiddlewaretoken":"kgEviC68d6OAB23v5fZlu0e1GO5oig7c","next":"/","submit":"Log+in"}

have {}


so ,login error

would you help me ?

@troyanskiy
Copy link
Owner

That is normal.
Your server does not expect to receive JSON body. It expect to receive application/x-www-form-urlencoded (regular form) data.
For now the library sends only JSONs.

@gasparherrera
Copy link

gasparherrera commented Dec 23, 2016

use JWT for this, personally I use https://github.com/GetBlimp/django-rest-framework-jwt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants