0

我正在构建与 django 服务器对话以获取数据的 IOS 应用程序。

这个应用程序使用 facebook 身份验证进行登录,所以我的想法是这样的:

在 IOS 应用程序中,单击登录按钮(fb auth)后,我们将获取用户数据(如来自 facebook 的用户名、电子邮件等)和 access_token。我会将用户名和访问令牌存储在 IOS 应用程序的某个地方(如会话),并且对于每次调用服务器以获取数据,我也会发送这两个(用户名和访问令牌)。

在服务器中,美味的派有类似 Authentication 的东西,可以像这样自定义:

class SillyAuthentication(Authentication):
def is_authenticated(self, request, **kwargs):
    user = User.objects.get(username=username)  -- username sent from ios app.

    #checking token sent now with the token saved during registration.
    #I hope, fb sends same authtoken everytime he logins.
    if user.userprofile.access_token == access_token: 
      return True

    return False

所以,这意味着,每次从 ios 应用程序发送请求时,它都需要发送用户名,accesstoken。这是我想到的,但不确定我是对还是错。

4

0 回答 0