Symfony 在nelmio沙盒中添加oauth2支持

Symfony 在nelmio沙盒中添加oauth2支持,symfony,oauth-2.0,fosrestbundle,nelmioapidocbundle,Symfony,Oauth 2.0,Fosrestbundle,Nelmioapidocbundle,我正在Symfony2(用FosRestBundle创建)中开发一个restapi 在启用oauth之前,我可以在提供的沙箱中尝试API方法 例如: GET /api/products/{id}.json GET /api/products/{id}.json?access_token=ZWRhNTE2MGUzZWE4ZTIzNDIxMGUxNjZkY2Yx... 但是,既然启用了oauth,为了调用API方法,我必须将oauth标记添加为查询字符串 例如: GET /api/product

我正在Symfony2(用FosRestBundle创建)中开发一个restapi

在启用oauth之前,我可以在提供的沙箱中尝试API方法

例如:

GET /api/products/{id}.json
GET /api/products/{id}.json?access_token=ZWRhNTE2MGUzZWE4ZTIzNDIxMGUxNjZkY2Yx...
但是,既然启用了oauth,为了调用API方法,我必须将oauth标记添加为查询字符串

例如:

GET /api/products/{id}.json
GET /api/products/{id}.json?access_token=ZWRhNTE2MGUzZWE4ZTIzNDIxMGUxNjZkY2Yx...
这些api调用在nelmio之外工作,没有任何问题

为了在nelmio中激活对oauth的支持,我在
/app/config.yml
中添加了以下配置:

nelmio_api_doc: 
    sandbox:
        authentication:            
            name: access_token      
            delivery: http
            type:     bearer
之后,它会在屏幕顶部请求一个
api键
,但是如果我在那里设置了oauth令牌,那么在尝试使用沙箱时仍然会收到未经授权的响应


知道如何解决这个问题吗?

我还有一个基于FOSRestBundle的API。我不确定您是否需要在身份验证块中强制输入名称

这个配置对我有用:

nelmio_api_doc:
    name: My awesome service
    sandbox:
        authentication:
            delivery: http
            type:     bearer

尝试配置
delivery:query
Oterwise,您可以在field:Header HTTP中使用令牌设置它,如下所示:
Authorization=Bearer