Gerwin
2010-Jul-01 23:31 UTC
How to communicate with Rails App from external C++/C# application using REST?
Hi, I was wondering how to communicate with my web app from e.g. a C++/C# application. I know how to use the HTTP Rest methods but was wondering about the following: * How to use POST with the authenticity_token (how do I get the token?) * How to maintain a session (i.e. login and keep the session)? thanks! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jason Roelofs
2010-Jul-02 00:27 UTC
Re: How to communicate with Rails App from external C++/C# application using REST?
On Jul 1, 2010, at 7:31 PM, Gerwin wrote:> Hi, > > I was wondering how to communicate with my web app from e.g. a C++/C# > application. I know how to use the HTTP Rest methods but was wondering > about the following: > > * How to use POST with the authenticity_token (how do I get the > token?) > * How to maintain a session (i.e. login and keep the session)? > > thanks! > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >For any method that needs to be POSTed to, you have to turn off the authenticity token check for that action, or that entire controller. This is as simple as: skip_before_filter :verify_authenticity_token Maintaining a session is usually done manually, where you have a /login that returns a login token, then every subsequent API request has to include that token or the request is dropped. It''s up to the application to keep track of who is logged in and which tokens are valid. If you want to use a real Rails session, then whatever you use to communicate needs to know how to work with cookies. There are plenty of HTTP client libraries out there, you''ll need to find the one that works w/ what you need. Jason -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.