F
F
Fires2016-12-25 11:23:43
Django
Fires, 2016-12-25 11:23:43

How to implement social authorization through django-rest-auth?

The official django-rest-auth documentation only says about setting up an endpoint for a post request.
And about where, in fact, to register secret keys and id's of applications (for example, vk or google) nothing. I found materials that say that you need to write in settings.py:

SOCIAL_AUTH_VK_OAUTH2_KEY = 'id_vk_app'
SOCIAL_AUTH_VK_OAUTH2_SECRET = 'secret_key_vk_app'

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'PRETTY_VERBOSE_GOOGLE_APP_ID'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'GOOGLE_APP_SECRET'

And links to authorization through these services need to be done manually. That is, the following scheme emerges:
1. The user on the site presses the social registration button
2. With our function we redirect him to the authorization address through the service (vk, google)
3. The user confirms the authorization.
4. The service redirects the user via a GET redirect with a request. That is, it does not call the configured endpoint
5. We (somehow) respond to this GET request, parse it and pass the necessary parameters (token or code) to the POST request of the django-rest-auth endpoint.
6. And here I have problems.
To check if the configured endpoint works at all, I manually sent a POST request with the specified token. As a result, django gave me the error "SocialApp matching query does not exist." and I don’t know what to do next .. And how in general it needs to be configured correctly. I would be grateful for any help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
webbus, 2016-12-25
@webus

Дак заполните модель SocialApp в админке то. Там прописывается ключ и токен соц.сети.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question