开发者

Rails: InvalidAuthenticityToken while token is supplied

开发者 https://www.devze.com 2023-01-21 09:59 出处:网络
I\'m trying to use an Java Applet for uploading files to my rails application. However I keep getting the following error and I can\'t figure out why:

I'm trying to use an Java Applet for uploading files to my rails application. However I keep getting the following error and I can't figure out why:

Processing CategoriesController#upload_image (for 127.0.0.1 at 2010-10-18 20:32:54) [POST] Parameters: {"partitionIndex"=>"0", "fileId"=>"8278320", "lastModified"开发者_StackOverflow社区=>"2010-09-18T14:31:12.610-0500", "fileLength"=>"18571", "fileName"=>"dreamstime_1038438.jpg.zip", "partitionCount"=>"1", "authenticity_token"=>"NHX938BYOQr/B4t1pb4pTMlgEFumfveXGxtROSChJpk=", "file"=>#}

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): :10:in synchronize' C:/Ruby/lib/ruby/1.9.1/webrick/httpserver.rb:111:inservice' C:/Ruby/lib/ruby/1.9.1/webrick/httpserver.rb:70:in run' C:/Ruby/lib/ruby/1.9.1/webrick/server.rb:183:inblock in start_thread'

I included the parameter authenticity_token as you can see above. The authenticity_token parameter is generated by form_authenticity_token(). In the same page there is a form and the authenticity_token is exactly the same. Any ideas what I'm overlooking here?


Authenticity token is used to prevent CSRF attacks (more info here: Understanding the Rails Authenticity Token).
Maybe your applet is not maintaing its session? and each request is being sent as a separate session? This would cause the error you're facing to happen.

0

精彩评论

暂无评论...
验证码 换一张
取 消