从php客户端调用rest post api时CSRF令牌无效 [英] CSRF token is invalid when calling rest post api from php Client

查看:34
本文介绍了从php客户端调用rest post api时CSRF令牌无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Symfony 中创建了一个 rest api.它使用表单让客户端发送数据.我在 setDefaultOptions 中使用了 'csrf_protection' => false,但仍然收到错误

I have created a rest api in Symfony. It uses form for the client to send the data. I have used 'csrf_protection' => false in setDefaultOptions, but still getting the error

CSRF 令牌无效.请尝试重新提交表单

The CSRF token is invalid. Please try to resubmit the form

推荐答案

您是否通过 NelmioApiDocBundle sanbox,还是您从前端的表单发送数据?您确定您没有将 csrf_protection 请求参数发送到您的 api 吗?

Did you test your api over NelmioApiDocBundle sanbox, or your sending data from form on frontned side? Are you sure that your not sending csrf_protection requsest parameter to your api?

这篇关于从php客户端调用rest post api时CSRF令牌无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆