Использование django-oauth2 для фреймворка отдыха django с LinkedIn - PullRequest
0 голосов
/ 21 ноября 2018

Я использую остальную часть django OAuth2 Toolkit.Я все настроил, и все вроде бы нормально, за исключением того, что LinkedIn возвращает 401 несанкционированный ответ, когда я пытаюсь получить токен доступа.Трассировка:

2018-11-21 14:28:22,904 [middlewares 70] INFO: {"method": "POST", "user_id": 234630, "request_post_body": {"authorization_grant_type": "authorization-code", "client_id": "foo", "csrfmiddlewaretoken": "foobar", "initial-client_id": "foo", "initial-client_secret": "bar", "redirect_uris": "http://xeniadev.com:3000/linkedin-login-redirect", "user": "234630", "_save": "Save", "name": "LinkedIn", "client_secret": "bar", "client_type": "public"}, "path": "/admin/oauth2_provider/application/1/change/", "device_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36", "user": ""}
[21/Nov/2018 14:28:22] "POST /admin/oauth2_provider/application/1/change/ HTTP/1.1" 302 0
2018-11-21 14:28:23,830 [middlewares 70] INFO: {"method": "GET", "user_id": 234630, "user": "", "path": "/admin/oauth2_provider/application/", "device_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"}
[21/Nov/2018 14:28:23] "GET /admin/oauth2_provider/application/ HTTP/1.1" 200 2874
2018-11-21 14:28:23,920 [middlewares 70] INFO: {"method": "GET", "user_id": 234630, "user": "", "path": "/admin/jsi18n/", "device_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"}
[21/Nov/2018 14:28:23] "GET /admin/jsi18n/ HTTP/1.1" 200 909
2018-11-21 14:28:32,895 [resource 74] DEBUG: Dispatching token_type Bearer request to <oauthlib.oauth2.rfc6749.tokens.BearerToken object at 0x12001b4c0>.
2018-11-21 14:28:32,895 [oauth2_endpoints 58] DEBUG: Dispatching grant_type convert_token request to <rest_framework_social_oauth2.oauth2_grants.SocialTokenGrant object at 0x11d9f86d8>.
2018-11-21 14:28:32,895 [refresh_token 58] DEBUG: Validating refresh token request, <oauthlib.Request url="/auth/convert-token", http_method="POST", headers="", body="<SANITIZED>&backend=linkedin-oauth2&client_id=foo&grant_type=convert_token">.
2018-11-21 14:28:32,963 [oauth2_validators 243] DEBUG: Application '77ha5jwgczyohk' has type 'public'
2018-11-21 14:28:32,964 [base 147] DEBUG: Validating access to scopes ['read', 'write'] for client 'foo' (<Application: LinkedIn>).
2018-11-21 14:28:32,978 [connectionpool 813] DEBUG: Starting new HTTPS connection (1): api.linkedin.com:443
2018-11-21 14:28:33,320 [connectionpool 393] DEBUG: https://api.linkedin.com:443 "GET /v1/people/~:(email-address,first-name,headline,id,industry,last-name)?format=json HTTP/1.1" 401 None
2018-11-21 14:28:33,324 [middlewares 70] INFO: {"method": "POST", "user": "AnonymousUser", "path": "/auth/convert-token", "device_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.1 Safari/605.1.15", "request_post_body": {"grant_type": "convert_token", "backend": "linkedin-oauth2", "client_id": "foo", "token": "footokenbar"}}
2018-11-21 14:28:33,325 [log 228] WARNING: Unauthorized: /auth/convert-token
[21/Nov/2018 14:28:33] "POST /auth/convert-token HTTP/1.1" 401 79

К сожалению, ни эта трассировка, ни консоль разработчика linkedin ничего не говорят мне о том, почему это происходит.Client_id и client_secret определенно верны

...