问题描述
我正在尝试将登录与linkedin集成,但我无法获取个人资料图片、电子邮件地址、个人资料网址和其他重要详细信息。
这是我到现在为止所做的。
SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY = 'Client ID'
SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET = 'Client Secret'
SOCIAL_AUTH_LINKEDIN_OAUTH2_ScopE = ['r_liteprofile','r_emailaddress',]
# SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = ['profile_url','email_address','headline','industry']
SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = ['email-address','formatted-name','profile-url','picture-url']
SOCIAL_AUTH_LINKEDIN_OAUTH2_EXTRA_DATA = [
('id','id'),('firstName','first_name'),('emailAddress','email_address'),('lastName','last_name'),('displayImage','profilePictures'),('publicProfileUrl','profile_url'),]
我也尝试设置这样的管道
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details','social.pipeline.social_auth.social_uid','social.pipeline.social_auth.auth_allowed','social.pipeline.social_auth.social_user','social.pipeline.user.get_username','social.pipeline.user.create_user','social.pipeline.social_auth.associate_user','social.pipeline.social_auth.load_extra_data','social.pipeline.user.user_details'
)
我用 _,- 等尝试了不同的组合,但没有任何效果,都给出与
相同的输出{
"auth_time": 1623340190,"id": "lIkisJgyIT","expires": 5184000,"first_name": {"localized": {"en_US": "Akash"},"preferredLocale": {"country": "US","language": "en"}},"last_name": {"localized": {"en_US": "Rathor"},"email_address": null,"profilePictures": null,"profile_url": null,"access_token": "fulltokenid"
token_type": null
}
还有一个困惑,当我在我的应用程序上使用linkedin登录并再次尝试使用linkedin登录时,这是用户已经通过身份验证的明显错误,如果用户已经通过身份验证,我不确定我如何设置条件那么用户将无法再次尝试登录。
这是我的views.py文件
from django.shortcuts import render
# Create your views here.
def login(request):
return render(request,'login.html')
def home(request):
return render(request,'home.html')
这是我的应用程序 urls.py
from django.contrib import admin
from django.urls import path,include
from django.contrib.auth import views as auth_views
from core import views
urlpatterns = [
path('admin/',admin.site.urls),path("login/",views.login,name="login"),path("logout/",auth_views.logoutView.as_view(),name="logout"),path('social-auth/',include('social_django.urls',namespace="social")),path("",views.home,name="home"),]
任何帮助将不胜感激。谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)