簡體   English   中英

python-social-auth +移動應用

[英]python-social-auth + mobile app

我有一個Django應用,並且為移動應用創建了API。 當涉及到用戶身份驗證時,我簡單地獲取登錄名+密碼並執行標准的django登錄名。 用戶登錄后,我生成一個令牌,將其保存並提供給移動應用程序。

現在談到Facebook,我想實現python-social-auth庫。 我確實知道如何為標准網絡實施它,這確實是微不足道的。 但是我不知道如何將其實現到我的移動API中以及如何在其中合並我的令牌。

只是在想...是否有可能進行編程身份驗證,所以我將能夠創建API方法並從那里調用社交身份驗證內容? 但是,在Facebook端的“允許您的個人資料訪問XY應用程序”頁面怎么樣?

任何建議都會有所幫助。 先感謝您。

文檔描述了如何簡單地提供access_token來認證/創建用戶。

from django.contrib.auth import login

from social.apps.django_app.utils import psa

# Define an URL entry to point to this view, call it passing the
# access_token parameter like ?access_token=<token>. The URL entry must
# contain the backend, like this:
#
#   url(r'^register-by-token/(?P<backend>[^/]+)/$',
#       'register_by_access_token')

@psa('social:complete')
def register_by_access_token(request, backend):
    # This view expects an access_token GET parameter, if it's needed,
    # request.backend and request.strategy will be loaded with the current
    # backend and strategy.
    token = request.GET.get('access_token')
    user = request.backend.do_auth(request.GET.get('access_token'))
    if user:
        login(request, user)
        return 'OK'
    else:
        return 'ERROR'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM