我为Drupal 8 REST调用创建了一个自定义资源。由于某些原因,我无法从身份验证提供程序中看到basic_auth或token_bearer。我安装了simple_oauth,仍然看不到basic_auth或token_bearer。

我使用的代码如下所示。
id: sample_index_resource
plugin_id: sample_index_resource
granularity: resource
configuration:
GET:
supported_formats:
- json
supported_auth:
- 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
}需要启用模块,以便能够使用basic_auth作为身份验证提供程序。我不知道应该启用哪个模块才能使用token_bearer。
要将token_bearer作为身份验证提供程序,需要安装哪些模块?
发布于 2018-08-22 07:57:53
我认为您的yml语法是错误的(或过时的),请查看rest.resource.entity.node.yml以获得一个正确的示例。或者使用"REST“模块来指定资源。
它应该看起来更像:
configuration:
methods:
- GET
- POST
- PATCH
- DELETE
formats:
- hal_json
authentication:
- basic_authhttps://drupal.stackexchange.com/questions/267955
复制相似问题