2

Error

{
    "error":"invalid_request",
    "error_description":"redirect_uri is incorrect, check application redirect uri in the settings page"
}

settings.py

AUTHENTICATION_BACKENDS = (
    'social.backends.vk.VKOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)
SOCIAL_AUTH_VK_OAUTH2_KEY = '****'
SOCIAL_AUTH_VK_OAUTH2_SECRET = '*****'

On vk.com http://127.0.0.1:8000/complete/vk-oauth2 as redirect URI

Anonymous
  • 11,740
  • 3
  • 40
  • 50
  • try to use http://localhost:8000/complete/vk-oauth2 as redirect URI and open your browser to open http://localhost:8000 and then try to login . – vikas0713 Jul 11 '16 at 17:53
  • i tried, it didn't help – Maxim Anatol'evich Borovsky Jul 11 '16 at 18:15
  • Sorry, but redirect uri errors usually caused by mismatching of requested uri or callback uri(redirect uri). – vikas0713 Jul 11 '16 at 18:47
  • Make shure that redirect_uri reali is 'http://127.0.0.1:8000/complete/vk-oauth2', you need to view the network requests in the browser (use https://developers.google.com/web/tools/chrome-devtools/profile/network-performance/resource-loading?utm_source=dcc). – Peter Jul 13 '16 at 08:59

2 Answers2

1

"social_auth" builds the complete URL via Django, it looks at X_FORWARDED_FOR header. If you have installed locally Nginx, config near will help you:

server {
    client_max_body_size 20M;
    listen 80;
    server_name example.loc;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
adw0rd
  • 1
  • 5
0

I see network request and in it was param redirect_uri:

http://localhost:8000/complete/vk-oauth2/.

I paste it in redirect uri on vk.com. And authorizing is ended successfully. To see request press f12 and go to tab network (in Firefox).