Exposing Rails/Devise Authentication to iOS application Exposing Rails/Devise Authentication to iOS application ios ios

Exposing Rails/Devise Authentication to iOS application


The fastest way would be to simply enable http_authenticatable and pass the username and password through HTTP Basic Auth. While that's the easiest way, it means you have to store the users password in plaintext and send it along with every request you make.

A better option is token authentication, you can pass it through parameters or HTTP Basic Auth (in which case you can set the password to "X" and the token to the username). The advantage to this is that you can just use the username/password initially to get the token and then use that for any further authentication.

The simplest way to do token authentication with the minimum amount of code would be to enable HTTP authentication in Devise and setup a new controller that requires the user is logged in and all it does is output the result of reset_authentication_token. Once you have the token you would then pass that to any future HTTP authentication requests to log them in.