English 中文(简体)
通过Rails API使用脸书进行认证
原标题:Authentication using Facebook via Rails API

我的铁路应用程序用户可以使用其中一种方式认证:

  • Using their Facebook account
  • Using our own authentication

我在Android上使用Facebook SDK,在铁路上使用devise omniauth

我该如何对照安卓的铁路应用认证 这样我才能从服务器上 获取我需要的信息?

“强势”NB

最佳回答

使用fb_graph 宝石(而非fbraph!)可以做到这一点。

你可以把它添加到你的宝石档案里 然后做

user = FbGraph::User.me(token).fetch

where token is the oauth token you got by using, for example, the Facebook SDK on Android. user.email will be the user s email address (if you set up the necessary permissions).

您可以使用此 URL 测试 :

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token
问题回答

这完全取决于您的认证系统如何运作。 您需要在服务器上创建一个 API, 以便处理 Android 应用程序的通信, 并在使用 API 的两者之间传递信息 。

Niraj Shah 完全正确, 尽管答案可能不够详细。 深入回答你的问题, 请查看 < a href=" http://railscasts. com/ episodes/352-securing- an- api" rel = “ nofollow” >, 以了解最近才发行的 Ryan Bates < / a > 的 API 轨迹。 它覆盖 HTTP Basic Auth 。

您也可以查看更先进的选项, 以确保您的 API / 提供注册用户访问他们的数据。 有关此选项的栏杆也显示 : < a href=" http://railscasts. com/ episodes/353- oauth- with- hormenders" rel= “ nofollow” > http://railescasts. com/ episodes/353- oauth- with- horterworders < / a > - 尽管这是一个积极的插曲, 所以您需要注册才能观看它 。

弗朗西斯科 我也有同样的需求

使用 Sign_aucontintikaable 设计的情景似乎很简单, 应该是个问题, 但我不确定处理Facebook情景的最佳方法。 在网络上, FBauth I 使用此处所记载的omniauth- facebook : < a href="https://github.com/plataformatec/devise/ devool", https://github.com/plataformatec/devise/wiki/ OmniAuth:-Overview 。 我认为这使用OAuth 和 FB 来作为提供者, 这样它很有可能让与 OAuth 一起的关于门卫安全 API 的最新的铁路安全中心能够做这个把戏。 我尝试过它, 但它会很快做到, 除非你打我。 这里的链接是: < a href="http://rails/ arrights 353-oth- hous- hostarders: relormacastors.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签