Skip to main content
1 of 3
jebbie
  • 131
  • 1
  • 3

How to login into drupal 8 trough the REST API?

Ok i've spent my whole afternoon trying to get this running:

  • Setup a freshly installed Drupal 8

  • Activate the WebServices (HAL, HTTP Basic Auth, Restful Webservices, Serialization)

  • Install REST UI Module

  • Activate the REST Module for e.g. /user/{user} under Configuration -> Web-Services -> REST (i'm activating GET/POST with json and basic_auth)

  • Fix the permissions so all "authenticated user" can access the Restful Webservices for User content

I basically followed this tutorial to get there: https://drupalize.me/blog/201401/introduction-restful-web-services-drupal-8

Then i go forward and create a POST call looking like this:

GET http://{my-host}/user/testing

// with following headers obj
{
  'Authorization': 'Basic dGVzdGluZzptYXN0ZXI=',
  'Content-Type': 'application/json'
}

Well, the user "testing" really exists, i've checked this like 100 times. The Basic Authorization user i'm giving him (i obfuscated the data here since it is still plain text base64) - believe me, it is a correct credential too, even from the admin user.

The path is correct too with /user/{user} - but he is always returning a 404 Not Found ...? Why?

Well what i try to achieve is a login trough a REST API call - so i can login with an existing drupal user from an external system (auth0). As far is i understood from the docs this should all be possible with the /user/{user} endpoint - but i'm totally unsure because i couldn't find any working examples for it.

jebbie
  • 131
  • 1
  • 3