FOSOAuthServerBundle+;FOSRestBundle+;CamelCase=未进行身份验证

FOSOAuthServerBundle+;FOSRestBundle+;CamelCase=未进行身份验证,rest,fosrestbundle,symfony-2.8,camelcasing,fosoauthserverbundle,Rest,Fosrestbundle,Symfony 2.8,Camelcasing,Fosoauthserverbundle,我一直在使用Symfony 2.8开发我的服务器,构建一个rest api,它以camelCase样式返回json对象,现在的问题是,当我集成OauthServer包时,它会启动此错误无效的grant_类型参数或参数缺失“,我知道发生这种情况是因为我在fos\u rest配置中使用了array\u normalizer:fos\u rest.normalizer.camel\u keys主体侦听器。这里是我在configuration.yml中的代码: fos_rest: #other

我一直在使用Symfony 2.8开发我的服务器,构建一个rest api,它以camelCase样式返回json对象,现在的问题是,当我集成OauthServer包时,它会启动此错误
无效的grant_类型参数或参数缺失“
,我知道发生这种情况是因为我在
fos\u rest
配置中使用了
array\u normalizer:fos\u rest.normalizer.camel\u keys
主体侦听器。这里是我在
configuration.yml
中的代码:

fos_rest:
    #other listeners#
    body_listener:
        array_normalizer: fos_rest.normalizer.camel_keys
    zone: 
         - { path: ^/api }
firewalls:
    oauth_token:
        pattern: ^/oauth/v2/token
        security: false
    api:
        pattern: ^/api                             
        fos_oauth: true                            
        stateless: true                            
        anonymous: false   
这里是
security.yml
中的Oauth配置:

fos_rest:
    #other listeners#
    body_listener:
        array_normalizer: fos_rest.normalizer.camel_keys
    zone: 
         - { path: ^/api }
firewalls:
    oauth_token:
        pattern: ^/oauth/v2/token
        security: false
    api:
        pattern: ^/api                             
        fos_oauth: true                            
        stateless: true                            
        anonymous: false   
我发现我不是第一个发生这种情况的人,并且添加了
区域
属性来缓解这种情况,但在我的例子中,它只适用于
^/api
下的所有内容,因为当我更改模式时,它会停止使用侦听器,但当我调用
^/oauth/v2/token
路径时,它似乎忽略了
区域
给定路径

要检索我的令牌,我将使用下一个POST请求:

{
    grant_type= "password" 
    client_id= "clientId"
    client_secret= "clientSecret"
    username= "user"
    password= "password"
}
我想澄清的是,如果我停用侦听器,我会成功获得令牌,但我的应用程序的其余部分会停止工作,因为它到处都使用camelCase,我知道曾经的替代方法是在客户端序列化我的数据,但目前它相当复杂


我做错了什么?我想不出我遗漏了什么。

作为一种解决方法,你可以用它来代替
POST
GET
这样

http://example.com/oauth/v2/token?client_id=[CLIENT_ID]&client_secret=[SECRET]&grant_type=password&username=[USERNAME]&password=[PASSWORD]
那么你就不必担心正文序列化程序了