![](/img/trans.png)
[英]Python-social-auth pipeline returns TypeError when I'm trying to get access_token
[英]Using python-social-auth I'm looking to access what backend provider the person is using in the middle of the pipeline
我的指導線在下面
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',
'create_user_and_set_email_as_username',
'social.pipeline.social_auth.associate_by_email',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
)
我創建的create_user_and_set_email_as_username
函數是為用戶做一些額外的事情的。 到了這個階段,在該功能中,我希望能夠踢出不使用特定oauth客戶端的用戶。 (我們有一些公司客戶想要強迫其雇員使用azure oauth2)。
我不知道如何訪問該函數中當前使用的后端。 IE,該人剛剛單擊的內容以及他們正在嘗試使用的服務。 嘗試了pdb'ing並查看了策略的組成部分,但看不到任何有用的內容。
我什至試圖在正確的地方這樣做嗎?
如何訪問他們嘗試使用的后端。 嘗試使用strategy.get_backends(),但列表可能不是當前列表。
我明白了我的意思。
說expected_oauth_provider
是您希望他們使用的東西。 然后,在添加到管道中的任何函數中,您都應該使用** kwargs並可以訪問它們在其中實際使用的內容。
if expected_oauth_provider != kwargs.get('backend').name:
return HttpResponse("You cannot use your companies accounts that are not " + rule.force_oauth_provider, status=405)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.