How to authenticate iOS/iPhone users with remote web application and re-use authentication ticket in future requests to the same web application?

后端 未结 4 2083
无人及你
无人及你 2021-01-31 11:14

I am building an iOS application and I need to be able to make authenticated requests to a Rails 3 application for various bits of data. The Rails 3 application is using omniau

4条回答
  •  渐次进展
    2021-01-31 11:34

    For my app this is what I'm doing.

    My app is using devise with omniauth for login and user stuff. Devise by itself can generate a unique token, with the flag token_authenticatable. So on my login request, if the login is successful I reply with a JSON representation of my user and my user token. I save all that on the phone memory.

    Then on every request I add the param auth_token=MY_USER_TOKEN.

    And that's about it.

    I had just a problem with the Facebook auth, because I'm using the Ios facebook SDK, so I forward the FB token to my app, verify it, and then just return the same devise auth_token for all following requests.

提交回复
热议问题