本文介绍了Android应用程序和Web服务+ Facebook的登录之间的身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序的唯一登录选项是通过Facebook登录。我想使用的Web服务(ASMX),并在每个请求,服务器必须验证用户通过Facebook认证。我找到了解决方法:

我的问题是:

  1. 请我一定要每次发送的Facebook用户ID和令牌当我将请求发送到Web服务,或者使用一个Cookie(如果可能)
  2. 请我必须要注册的Web服务作为一个Facebook应用程序。我发现这一点: C#的Facebook SDK入门
解决方案

您的解决方案看起来不错。事实上,唯一Android客户端需要传递到Web服务的身份验证令牌。与认证令牌您可以授予权限的用户做任何事情,当然。所以,Android客户端必须要求用户输入您的Web服务将使用权限。

有关的两个问题:

  1. 没有。您应该只发送FB身份验证令牌一次。经过网络服务器可以检索FB用户的信息,你可以保存这些信息到数据库(在一个简单的用户模型),然后用自己的身份验证引擎创建会话(饼干,API令牌等。)

  2. 没有。你并不需要注册的Web服务作为一个FB的应用程序。正如我上面提到的,与FB认证令牌,你可以做很多事情。你还可以看到 Facebook的图形API

The only login option in my android application is login via Facebook. I would like to use Web service(asmx) and on each request, the server must validate that the user is authenticated via facebook. I found a solution:

My questions are:

  1. Do i have to send facebook user id and token each time when i send request to the web service or use a cookie(If it's possible)
  2. Do I have to register the web service as a facebook application. I found this:C# Facebook SDK Getting Started
解决方案

Your solution looks good. Actually, the only thing Android client needs to pass to web service is authentication token. With that authentication token you can do anything, of course with the permissions user granted. So, the Android client must ask user for the permissions your web service will use.

For your 2 questions:

  1. No. You should send FB authentication token one time only. After web server can retrieve user's info from FB, you can save these info to DB (within a simple User model) and then create session with your own authentication engine (cookies, API token, etc.)

  2. No. You don't need to register the web service as a FB app. As I mentioned above, with FB authentication token you can do many things. You can also see the Facebook Graph API

这篇关于Android应用程序和Web服务+ Facebook的登录之间的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:55