New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CURL call response : The CSRF token is invalid. #1
Comments
Hi the problem is about here: https://github.com/liuggio/symfony2-rest-api-the-best-2013-way/blob/master/app/config/security.yml#L26 in order to use the api you should use user and password, if you are not auth. you need the CSRF token, example html page, is a new feature described here symfony CSRF and REST |
How to authenticate as ROLE_API using curl call ? |
Hi liuggio |
Hi @svnindia please let me know if it works, and please could you provide a Pull request to the blog if you think this has to be modified? thanks |
Hi liuggio, First I need to Thank You, for writing a blog for how to use the FOS bundles.... If some step by step use case examples given it will be really helpful. You have already given some examples but as a New Bie to symfony I could not proceed further. :( After modifying the below code, I am able to post data. Need to look for a solution for auth, the above suggested not worked for me.... Thanks |
Thanks and YOURUSERNAME:YOURPASSWORD should be username and password of the security.yml |
Thanks liuggio. |
if you found a solution please maybe could help others. |
sure will share the code here. |
@svnindia same problem... Any solution? |
sorry I don't get the problem,
because it uses the # app/config/config.yml
fos_rest:
disable_csrf_role: ROLE_API please could you confirm that works also to you thanks |
For the moment I do in my form:
But it's not a good way... |
@liuggio the command Thanks. But I would open an issue to use FOSUserBundle with this api. |
I have tried with FOSOAuth and its working fine.... |
In Major websites for WebServices REST with OAuth used.(Facebook/twitter) |
|
I try use FOSOAuthServerBundle with FOSUserBundle: My security.yml:
My config.yml
In my browser I have this error in
I think I must create a client to oauth... see https://gist.github.com/ornj/5061326. Any idea? ...I think I will use WSSE authentication, it's more adapted for my project. |
Hi,
I am new to symfony. I have installed the symfony blog code and its working fine on web browser (forms& api doc).
But If I tried on curl call I am getting error
curl -X POST -d '{"title":"title","body":"body"}' http://localhost:8000/api/v1/pages.json --header "Content-Type:application/json"
-header "Content-Type:application/json"
{"code":400,"message":"Validation Failed","errors":{"errors":["The CSRF token is invalid. Please try to resubmit the form."],"children":{"title":[],"body":[]}}}
{"code":400,"message":"Validation Failed","errors":{"errors":["The CSRF token is invalid. Please try to resubmit the form.","This form should not contain extra fields."],"children":{"title":{"errors":["This value should not be blank.","This value should not be null."]},"body":[]}}}
Help me to understand and solve the issue....
Thanks,
SVN
The text was updated successfully, but these errors were encountered: