微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用 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 举报,一经查实,本站将立刻删除。