Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By paugonzaleza on
Hello everyone, I'm trying to login using rest with cookie in drupal 8 (like drupal 7 but not using basic auth or oauth) following this guidelines: https://www.drupal.org/node/2076725
The basics is Post to user/ whith this json {"name":"","pass":"","form_id":"user_login_form"} but I receive the error No route found to "user"
I enabled Rest permisions to access POST and enabled user resource with cookie login (using REST UI).
I'm using alpha 14 at this time.
Anybody trying to login too?
Comments
user/login
Try POSTing to user/login
and setting the Accept header to application/json(see change record), and setting the Content-type header to application/x-www-form-urlencoded.You may have to append the credentials to the path, for example:
user/login?name=foo&pass=bar&form_id=user_login_form
When I perform this post
When I perform this post request it just loads the user/login form (unpopulated). If I goto it in the browser again I just see the form unpopulated. So no login happens - any ideas?
Does this mean that cookie
Does this mean that cookie authentication is not going to be used with REST Services in Drupal 8?
Same Problem
I'm having the same problem, I post to user/login and use this as my data:
{
form_id: 'user_login_form',
name: username,
pass: password
};
It works great in Postman, but when I do it in my webapp app, I get the same results (the unpopulated sign in page). I have CORS enabled, any ideas?
Thanks!
Nevermind
Never mind I figured out the solution, I had to serialize the data so (in Angular) I did this:
data: $httpParamSerializer(data)