Android应用程序和Web服务+ Facebook的登录之间的身份验证 [英] Authentication between Android app and web service + facebook login

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

问题描述

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

  

1)从Android应用程序验证用户对Facebook的,2)获取   FB身份验证令牌的Andr​​oid应用程序,3)转发的认证令牌   &放大器; Facebook的UID从机器人到Web服务器,4)在Web服务器上,使   Facebook的API调用与提交的令牌。

     

如果从Web服务器Facebook的API调用返回有效的身份验证,   和用户ID等于提交的Andr​​oid应用程序之一,   您的服务器可以信任的ID(功放,可以肯定的是,Android的   验证实)

     

<一个href="http://stackoverflow.com/questions/7756878/facebook-authentication-to-my-server-using-android">Link

我的问题是:

  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:

1) Authenticate user to Facebook from Android application, 2) Get the FB auth token to the android app, 3) Forward the authentication token & facebook UID from Android to web server, 4) On web server, make Facebook API call with the submitted token.

If the Facebook API call from web server returns valid authentication, and the user id is equal to the one submitted by Android application, your server can trust the id (& you can be sure that the Android authentication real)

Link

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的登录之间的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆