FOSOAuthServerBundle:无效的grant

编程入门 行业动态 更新时间:2024-10-09 07:21:16
本文介绍了FOSOAuthServerBundle:无效的grant_type参数或缺少参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Symfony 3.1和FOSRestBundle,FOSUserBundle和FOSOAuthServerBundle构建REST API.我已按照 gist.github/tjamps/11d617a4b318d65ca583 a>.

I'm trying to build a REST API using Symfony 3.1 and the FOSRestBundle, FOSUserBundle and FOSOAuthServerBundle. I managed to achieve this following the guide at gist.github/tjamps/11d617a4b318d65ca583.

我现在正在努力进行身份验证过程.当我使用请求正文中json编码的参数向服务器发出POST请求以进行身份​​验证(到localhost:8000/oauth/v2/token)时:

I'm now struggling at the authentication process. When I make a POST request to the server for authentication (to localhost:8000/oauth/v2/token) with the parameters encoded in json in the request body:

{ "grant_type": "password", "client_id": "1_myveryverysecretkey", "client_secret": "myveryverymostsecretkey", "username": "theuser", "password": "thepassword" }

其他HTTP标头如下:

The additional HTTP Headers are the following:

Accept: application/json Cache-Control: no-store, private Connection: close Content-Type: */json

根据指南的建议,数据库表oauth2_client中的客户端具有密码" grant_type a:1:{i:0;s:8:"password";}.

The client in the db table oauth2_client has the "password" grant_type a:1:{i:0;s:8:"password";}, as suggested by the guide.

服务器正在接受请求,但我总是得到响应

The server is accepting the request, but I always get the response

{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}

有什么建议我想念的吗?谢谢!

Any suggestions what I am missing? Thanks!

推荐答案

确实是FOSRestBundle 身体监听器是此问题的主要原因".

really the FOSRestBundle Body Listener is the main 'cause' of this issue.

数组标准化器配置

fos_rest: body_listener: array_normalizer: fos_rest.normalizer.camel_keys

它将_转换为驼峰式格式.

it converts _ to camel case format.

该解决方案目前已将其从我的配置中删除.

The solution was remove it of my configuration by the moment.

再次调用/oauth/v2/token端点:

{ "access_token": "NDBlZGViN2YwZGM5MTQ3ZTgwN2FhOGY4MDU4MTc1MTY2YzZmOThlMTdkM2JiZDJmMDVmNTg3MjU4N2JmODY3ZA", "expires_in": 3600, "token_type": "bearer", "scope": null, "refresh_token": "MDRiODllNjlhZWYxZjI5MjlhMzAxNGVhMDY5NjQxMmVmNDE5MzY3YzU0MGM0MDU1ZTVlY2Y2Zjg4ZTYyYzU3Mw" }

更多推荐

FOSOAuthServerBundle:无效的grant

本文发布于:2023-11-26 23:38:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635680.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:FOSOAuthServerBundle   grant

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!