Hi Oleg, your problem is that your POST-data is serialized as "JSON", but it's expected to be serialized as "X-WWW-FORM-URLENCODED". Take a look at: http://www.bennadel.com/blog/2615-posting-form-data-with-http-in-angularjs.htm
Or just use the native FormData XHR: https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects Best, Johnny On Tuesday, October 7, 2014 11:48:51 AM UTC+2, Oleg wrote: > > How to create this request by $resource/$http > > POST /oauth/token HTTP/1.1 > Host: server.example.com > Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW > Content-Type: application/x-www-form-urlencoded > > grant_type=password&username=johndoe&password=A3ddj3w > > I use > > $http({ > method: 'POST', > url: 'http://localhost:8001/token', > data: { > grant_type: 'password', > username: 'johndoe', > password: 'A3ddj3w' > }, > headers: { > 'Content-Type': 'application/x-www-form-urlencoded', > Authorization: 'Basic > MTphMzJjMGZkM2EyNTUyYzZjMDNiOThiMTJlNTUyOWQwMQ==' > } > }) > > But my request look like: > > > 1. Remote Address: > 127.0.0.1:8001 > 2. Request URL: > http://localhost:8001/token > 3. Request Method: > POST > 4. Status Code: > 404 Not Found > 5. Request Headersview source > 1. Accept: > application/json, text/plain, */* > 2. Accept-Encoding: > gzip,deflate > 3. Accept-Language: > ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 > 4. Authorization: > Basic MTphMzJjMGZkM2EyNTUyYzZjMDNiOThiMTJlNTUyOWQwMQ== > 5. Cache-Control: > no-cache > 6. Connection: > keep-alive > 7. Content-Length: > 67 > 8. Content-Type: > application/x-www-form-urlencoded > 9. Cookie: > > > sid=s%3ASlH1ffec8ImuCK3Bc8KyB5qMNlVroUoL.nLeKljOhlR2rxOJUvGwb8Xc0ILRwIHrqg2GMlC77N1I > 10. Host: > localhost:8001 > 11. Origin: > http://localhost:8001 > 12. Pragma: > no-cache > 13. Referer: > http://localhost:8001/registration > 14. User-Agent: > Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like > Gecko) Chrome/37.0.2062.120 Safari/537.36 > 6. Form Dataview sourceview URL encoded > 1. > {"grant_type":"password","username":"johndoe","password":"A3ddj3w"}: > 7. Response Headersview source > 1. Connection: > keep-alive > 2. Content-Type: > text/plain > 3. Date: > Tue, 07 Oct 2014 09:42:27 GMT > 4. Transfer-Encoding: > chunked > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
