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?


tyler.frankenstein’s picture

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

webbymatt’s picture

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?

adventurist’s picture

Does this mean that cookie authentication is not going to be used with REST Services in Drupal 8?

droti’s picture

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?


droti’s picture

Never mind I figured out the solution, I had to serialize the data so (in Angular) I did this:

data: $httpParamSerializer(data)