简体   繁体   English

Python社交身份验证Django Github OAuth

[英]Python Social Auth Django Github OAuth

I'm trying to integrate my Django website with Github Authentication using Python-Social-Auth library 我正在尝试使用Python-Social-Auth库将Django网站与Github身份验证集成

Configuration so far: 到目前为止的配置:

settings.py settings.py

INSTALLED_APPS += (
 ...
 "social_django",
 "social_core",

)

AUTHENTICATION_BACKENDS = [
    "account.auth_backends.UsernameAuthenticationBackend",
    "social_core.backends.github.GithubOAuth2",
]

TEMPLATES = [
    {
            ...
            'context_processors': [
                ...
                "social_django.context_processors.backends",
                "social_django.context_processors.login_redirect",
            ],
        },
    },
]

login.html 的login.html

<a href="{% url "social:begin" "GithubOAuth2" %}">Github</a>

urls.py urls.py

url("^socialaccounts/", include('social_django.urls', namespace='socialaccounts')),

But when I click the link, it shows a 404 Not Found Page. 但是,当我单击链接时,它显示404未找到页面。 And where do I put the secret key and other github configuration? 在哪里放置密钥和其他github配置?

They go in the project's settings.py file. 它们进入项目的settings.py文件中。

INSTALLED_APPS += (
 ...
 "social_django",
 "social_core",

)

AUTHENTICATION_BACKENDS = [
    "account.auth_backends.UsernameAuthenticationBackend",
    "social_core.backends.github.GithubOAuth2",
]

TEMPLATES = [
    {
            ...
            'context_processors': [
                ...
                "social_django.context_processors.backends",
                "social_django.context_processors.login_redirect",
            ],
        },
    },
]

SOCIAL_AUTH_GITHUB_KEY = ''
SOCIAL_AUTH_GITHUB_SECRET = ''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python social auth和Django-OAuth用户和Django用户之间是否存在1:1关系? - python social auth and Django - is there a 1:1 relationship between OAuth users and Django users? Django社交auth GitHub身份验证 - Django social auth GitHub authentication 如何将Django OAuth Toolkit与Python Social Auth结合使用? - How can I use Django OAuth Toolkit with Python Social Auth? Github 认证失败 | 蟒蛇社交认证 - Authentication failed in Github | python-social-auth 使用Python Social Auth过滤或限制Django中的一组用户使用Google-Oauth2登录 - Filtering or restricting Google-Oauth2 login to a set of users in Django using Python Social Auth 使用&#39;hd&#39;param(Django / python-social-auth)限制对某个域的Google OAuth访问权限 - Limit Google OAuth access to one domain using 'hd' param (Django / python-social-auth) HTTPError 403(Forbidden),Django和python-social-auth通过OAuth2连接到Google - HTTPError 403 (Forbidden) with Django and python-social-auth connecting to Google with OAuth2 Django中的Python社交认证,makemigrations检测不到任何变化 - Python social auth in Django, makemigrations detects no changes django-pipeline崩溃了python社会认证 - django-pipeline crashes python social auth Python社交auth Django管道非类型错误 - Python social auth Django pipeline nonetype errors
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM