英文:
django-allauth redirect confirm page
问题
在DJango上,我有一个应用程序。在登录部分,我已经使用DJango allauth实现了与Microsoft的身份验证。当我点击"登录"按钮与Microsoft登录时,会在重定向到Microsoft之前,将我重定向到一个页面,我必须点击"继续"按钮。我想要移除这个第二个页面,使其自动将我重定向到Microsoft页面。
我在我的"settings.py"文件中有以下内容:
SOCIALACCOUNT_PROVIDERS = {
'microsoft': {
'APP': {
'client_id': '',
'secret': '',
},
'SCOPE': ['User.Read'],
'AUTH_PARAMS': {
'prompt': 'select_account',
},
'INIT_PARAMS': {
'prompt': 'select_account',
},
'callback_url': 'https://myapp.test.com/accounts/microsoft/login/callback/',
},
}
ACCOUNT_EMAIL_VERIFICATION = 'None'
ACCOUNT_EMAIL_REQUIRED = False
我不知道应该做什么更改。
英文:
I have an app on DJango. In the login part I have implemented authentication with Microsoft using DJango allatuh. When I press the "sign in" button with microsoft, before redirecting to the microsof, it redirects me to a page where I have to press the "continue" button. I want to remove this second page so that it automatically redirects me to the microsoft page.
I have this on my "settings.py" file:
SOCIALACCOUNT_PROVIDERS = {
'microsoft': {
'APP': {
'client_id': '',
'secret': '',
},
'SCOPE': ['User.Read'],
'AUTH_PARAMS': {
'prompt': 'select_account',
},
'INIT_PARAMS': {
'prompt': 'select_account',
},
'callback_url': 'https://myapp.test.com/accounts/microsoft/login/callback/',
},
}
ACCOUNT_EMAIL_VERIFICATION = 'None'
ACCOUNT_EMAIL_REQUIRED = False
I don't know what to change
答案1
得分: 0
你可以使用以下代码来绕过确认页面:
<form method="post" action="{% url 'microsoft_login' %}">
{% csrf_token %}
<button type="submit" class="btn">
使用Microsoft登录
</button>
</form>
而不是:
{% provider_login_url 'microsoft' %}
英文:
You can use this code for bypass that confirmation page:
<form method="post" action="{% url 'microsoft_login' %}">
{% csrf_token %}
<button type="submit" class="btn">
Login with Microsoft
</button>
</form>
instead of:
{% provider_login_url 'microsoft' %}
答案2
得分: 0
代替 'prompt': 'select_account'
,你可以使用 'prompt': 'none'
。
SOCIALACCOUNT_PROVIDERS = {
'microsoft': {
'APP': {
'client_id': '',
'secret': '',
},
'SCOPE': ['User.Read'],
'AUTH_PARAMS': {
'prompt': 'none',
},
'INIT_PARAMS': {
'prompt': 'none',
},
'callback_url': 'https://myapp.test.com/accounts/microsoft/login/callback/',
},
}
ACCOUNT_EMAIL_VERIFICATION = 'None'
ACCOUNT_EMAIL_REQUIRED = False
英文:
Instead of 'prompt': 'select_account'
, you could use 'prompt': 'none'
SOCIALACCOUNT_PROVIDERS = {
'microsoft': {
'APP': {
'client_id': '',
'secret': '',
},
'SCOPE': ['User.Read'],
'AUTH_PARAMS': {
'prompt': 'none',
},
'INIT_PARAMS': {
'prompt': 'none',
},
'callback_url': 'https://myapp.test.com/accounts/microsoft/login/callback/',
},
}
ACCOUNT_EMAIL_VERIFICATION = 'None'
ACCOUNT_EMAIL_REQUIRED = False
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论