简体   繁体   English

通过Rails 4 API对Android应用进行身份验证

[英]Authenticating an android App to a Rails 4 API

I'd like to build an API for other partner Android Application but at the time this api would be a web app, so the user can login via the android app and web app. 我想为其他合作伙伴Android应用程序构建API,但当时该API可能是网络应用程序,因此用户可以通过android应用程序和网络应用程序登录。 I've manage sessions using the rails session[] hash, but when i tried to access from a node js application that I'm using for test it doesn't keep the session, i guess it's for the cookies. 我已经使用rails session []哈希管理会话,但是当我尝试从用于测试的节点js应用程序访问时,它无法保留会话,我想它是针对cookie的。

I was reading about devise, but i don't really understand it... I need some way to login, and retrieve data from the android device without sending the user id and the password each time a pull a request. 我正在阅读有关devise的内容,但我不太了解...我需要某种登录方式,并在每次请求请求时都无需发送用户ID和密码即可从android设备检索数据。

What would be the best way? 最好的方法是什么? Should I go with devise?... 我应该去设计吗?

Thanks in advance. 提前致谢。

You might be able to secure your APIs for the mobile client by securing the Rails APIs with OAuth. 您可以通过使用OAuth保护Rails API来保护移动客户端的API。 Then the Android client can authenticate via OAuth to your Rails app. 然后,Android客户端可以通过OAuth对您的Rails应用进行身份验证。

Check out the following gem: 查看以下宝石:

  • doorkeeper - A rails engine that turns your app in to an OAuth 2 provider so that you can secure your rails APIs with OAuth. Doorkeeper-一个Rails引擎,可将您的应用程序转换为OAuth 2提供程序,以便您可以使用OAuth保护Rails API。

Also, check out this great blog post about how to use Doorkeeper along with devise, etc: http://sameer.siruguri.net/blog/2013/06/23/railscast-gotcha-using-devise-doorkeeper-and-oauth2-defaults/ 另外,请查看有关如何与设计等一起使用Doorkeeper的出色博客文章http : //sameer.siruguri.net/blog/2013/06/23/railscast-gotcha-using-devise-doorkeeper-and-oauth2 -defaults /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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