2

I've developed a simple store application in Rails 3.0 with Devise as an authentication mechanism (only authorized users can access it). I also wrote a native android applicaion, from where I need to login to this web application, authenticate (using email, password) and access the default controller and get the data in JSON format.

So my questions are:

  1. How would I authenticate with Rails app from mobile app securely? Can I test this with curl program calling /users/sign_in? How would I specify the parameters (email and password) securely? What is the general convention in this situation?

  2. And how do I format data in JSON instead of default XML?

Any ideas? I appreciate your time and thoughts.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Atarang
  • 422
  • 1
  • 6
  • 22
  • Just wanted to point out similar question thread. http://stackoverflow.com/questions/7064803/rails-devise-http-authenticating-mobile – Atarang Dec 14 '11 at 06:55

1 Answers1

0

There is some tutorial,

Yes you can use cURL to test you RoR app.-

curl -v -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://localhost:3000/mycontroller -d "{\"jsonroot\":{\"a_key\":\"something\",\"b_key\":\"someotherthing\"}}"

To format data in JSON, there are various helpers available in ROR, like to_json and from_json.

Since you have already created the steps, going through this tutorial would be of help to you. Hope the tutorial helps.

inquisitive
  • 3,738
  • 6
  • 30
  • 56