gpt4 book ai didi

android - Android应用程序和网络服务之间的身份验证+ facebook登录

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:57:26 24 4
gpt4 key购买 nike

我的 android 应用程序中唯一的登录选项是通过 Facebook 登录。我想使用 Web 服务 (ASMX),并且在每次请求时,服务器都必须验证用户是否通过 facebook 进行了身份验证。我找到了一个解决方案:

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

我的问题是:

  1. 每次向网络服务发送请求时,是否都必须发送 facebook 用户 ID 和 token ?或者使用 cookie(如果可能的话)
  2. 我是否必须将网络服务注册为 Facebook 应用程序?我找到了这个: C# Facebook SDK Getting Started

最佳答案

您的解决方案看起来不错。实际上,Android 客户端唯一需要传递给 Web 服务的是身份验证 token 。使用该身份验证 token ,您可以做任何事情,当然需要用户授予的权限。因此,Android 客户端必须询问用户您的 Web 服务将使用的权限。

对于您的 2 个问题:

  1. 没有。您应该只发送一次 FB 身份验证 token 。 Web 服务器可以从 FB 检索用户信息后,您可以将这些信息保存到数据库(在简单的用户模型中),然后使用您自己的身份验证引擎(cookie、API token 等)创建 session

  2. 没有。您无需将 Web 服务注册为 FB 应用程序。正如我上面提到的,使用 FB 身份验证 token ,您可以做很多事情。您还可以看到 Facebook Graph API

关于android - Android应用程序和网络服务之间的身份验证+ facebook登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14685700/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com