使用 Allauth 和 rest-auth 在 Django rest 框架中配置 Apple 登录

问题描述

我正在将 Django + Django Rest Framework 用于为移动应用程序提供 RESTful 服务的项目。 现在我必须集成 Apple 登录

对于社交登录,我已经使用 Allauth + Allauth Socialaccount + rest-auth 登录 Facebook。

据 Allauth 文档报道,它似乎也支持 Apple。

阅读我读过的文档,有必要使用以下内容对其进行配置(进入 Django 设置):

    SOCIALACCOUNT_PROVIDERS = {
    "apple": {
        "APP": {
            # Your service identifier.
            "client_id": "your.service.id",# The Key ID (visible in the "View Key Details" page).
            "secret": "KEYID",# Member ID/App ID Prefix -- you can find it below your name
             # at the top right corner of the page,or it’s your App ID
             # Prefix in your App ID.
            "key": "MEMAPPIDPREFIX",# The certificate you downloaded when generating the key.
            "certificate_key": """-----BEGIN PRIVATE KEY-----
s3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr
3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3
c3ts3cr3t
-----END PRIVATE KEY-----
"""
        }
    }
}

我正在尝试使用已经描述的库进行第一次测试:

添加了我的网址:

url(r'^api/v1/users/applelogin',AppleLoginAPIView.as_view(),name='applelogin-user-url'),

我创建了我的视图:

class AppleLoginAPIView(SocialLoginView):
    adapter_class = AppleOAuth2Adapter
    callback_url = 'https://www.example.com'
    client_class = Appleoauth2client

在尝试第一个测试时,我遇到了一些错误,我发现有必要创建(到数据库中 .. 使用例如 Django-admin 选择 Apple 作为选定提供程序的社交应用程序。

是否需要请求的 Django 设置(如上所述)?

callback_url 的目的是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)