Social Endpoints (djoser)
https://djoser.readthedocs.io/en/latest/social_endpoints.html
#djoser
beta qualityとのこと
The list of providers is available at social backend docs.
https://python-social-auth.readthedocs.io/en/latest/backends/index.html#social-backends
url(r'^auth/', include('djoser.social.urls'))
https://github.com/sunscrapers/djoser/blob/2.2.2/djoser/social/urls.py
/o/{{ provider }}/が生える
GET
クエリパラメタ redirect_uri
200 OKで authorization_url が返る
POST
パラメタ code, state (application/x-www-form-urlencoded)
201 でtokenが返る
実装
views.py https://github.com/sunscrapers/djoser/blob/2.2.2/djoser/social/views.py
GETが実装されている
social_django(social-auth-app-django)のload_strategyとload_backendが呼び出されている
POSTはProviderAuthSerializerによる
serializers.py https://github.com/sunscrapers/djoser/blob/2.2.2/djoser/social/serializers.py
GoogleOAuth2のbackendでbackend.auth_complete()が
social_core.exceptions.AuthStateMissing: Session value state missing.
auth_completeはBaseOAuth2に実装されている
https://github.com/python-social-auth/social-core/blob/4.5.4/social_core/backends/oauth.py#L408
self.validate_state()でエラー
OAuthAuthのvalidate_state
https://github.com/python-social-auth/social-core/blob/4.5.4/social_core/backends/oauth.py#L91
self.get_session_state()がNone
デバッグしたところDjangoStrategyのsession_get("google-oauth2_state")がNoneを返している
GETで設定すべき?(strategyのsession_setだとうまくいかない)
State could not be found in server-side session data. status_code 400 #587
Browable APIならうまくいった(curlだからハマっていた)
Problem using social auth in stateless webapp #403