简体   繁体   中英

Rails authenticity token and Facebook

can anyone tell me how to post data from an facebook application to a rails backend? I have some trouble with the auth. token because the app called through a facebook canvas so the token will always be wrong.

I dont have code right now, its a simple dilemma with my understanding of this. So in the end i would like to use rails 3 to get some data from an application with the correct token.

Any help would be great!

In this case the authenticity token does not really apply. The authenticity token is there to make sure that users are making request from within your application. That is why the authenticity token is generated during an initial request to the application and then passed back during POST, PUT and DELETE requests. If you are using another application to make the requests, then you don't have the opportunity to generate the authenticity token on the initial call. This means you need to ignore the default authenticity token check for certain actions:

protect_from_forgery :except => [:update, :delete, :create]

or for your controller:

skip_before_filter :verify_authenticity_token

What you are actually doing is creating an API with which your facebook application can interact, and for APIs you need to use other forms of authenticity, like OAuth, to verify that the request is valid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM