'Redirect URI does not match registered redire

2019-07-20 14:35发布

问题:

I am using python-social-auth for authentication with social networks.

I have installed and configured everything. In the last step, I added these two action links:

<a href="{% url 'social:begin' 'facebook' %}">Login with Facebook</a>
<a href="{% url 'social:begin' 'instagram' %}">Login with Instagram</a>

Facebook login is working fine but instagram is giving me the following error:

{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered redirect URI"}

in my settings.py I have these:

SOCIAL_AUTH_INSTAGRAM_KEY = 'my_key'
SOCIAL_AUTH_INSTAGRAM_SECRET = 'my_secret'

and

INSTAGRAM_REDIRECT_URI = 'http://localhost:8000/shops/edit'

the most interesting part is that if I try to do this without python-social-aut, i.e. using these configurations:

INSTAGRAM_CLIENT_ID = get_env_setting('INSTAGRAM_CLIENT_ID')
INSTAGRAM_CLIENT_SECRET = get_env_setting('INSTAGRAM_CLIENT_SECRET')
INSTAGRAM_REDIRECT_URI = get_env_setting('INSTAGRAM_REDIRECT_URI')

It is just working fine.

I am thinking it has something to do with that python-social-auth app.

How can I fix it?

回答1:

Try to set SOCIAL_AUTH_INSTAGRAM_REDIRECT_URL for example

SOCIAL_AUTH_INSTAGRAM_REDIRECT_URL = 'http://localhost:8000/complete/instagram'

and check redirect uri in you instagram client settings.