I created a custom resource for a Drupal 8 REST call. For some reason, I can't see either basic_auth or token_bearer from the authentication providers. I installed simple_oauth and still can't see either basic_auth or token_bearer.

enter image description here

The code I am using is the following one.


id: sample_index_resource
plugin_id: sample_index_resource
granularity: resource
    - json
    - basic_auth
    - cookie
    - token_bearer


 * Provides a Sample Index Resource
 * @RestResource(
 *   id = "sample_index_resource",
 *   label = @Translation("Sample Index Resource"),
 *   uri_paths = {
 *     "canonical" = "/api/sample-response/{category}/{alias}"
 *   }
 * )
class SampleResource extends ResourceBase {
* Responds to entity GET requests.
* @return \Drupal\rest\ResourceResponse
public function get($category, $alias) {
  // Return response

The HTTP Basic Authentication module needs to be enabled to be able to use basic_auth as authentication provider. I don't know which module I should enable to be able to use token_bearer.

What module do I need to install to get token_bearer as authentication provider?

1 Answer 1


I think your yml syntax is wrong (or out-dated) look at rest.resource.entity.node.yml for a correct example. Or use the "REST UI" module to specify your resources.

It should look more like:

    - GET
    - POST
    - PATCH
    - DELETE
    - hal_json
    - basic_auth
  • Looks interesting. Thanks Rainer. I'll give it a try and will get back to you. Aug 22, 2018 at 8:15
  • I didn't know that I needed to enable "HTTP Basic Authentication" module to be able to use "basic_auth". Though, I have changed the syntax as per the updated one. Just looking which module should I use to be able to use "token_bearer" for the authentication providers. Thanks Rainer Aug 22, 2018 at 8:40
  • hi rainer, you might know which module should I enable to be able to use "token_bearer"? Aug 22, 2018 at 9:03
  • Should work with "Simple Oauth" module - take care for that issue: drupal.org/project/simple_oauth/issues/2957081 Aug 22, 2018 at 9:06
  • oh.. got it. Thank you so much for your help Rainer :) Aug 22, 2018 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.