tutor
tutor copied to clipboard
Mismatching redirect URI.
yes
Bug description
When i want to signin in studio, I always get this error:
Error: invalid_request Mismatching redirect URI.
Here is my cms-sso config:
How to reproduce
Environment
This is in Docker environment Additional context
Thx a lot for your help :)
Hi @AmsellemJoseph
We've face the same problem in our OpenEdx environment. We followed this solution to solve the problem.
To implement it into tutor we created a plugin with the following code (I've added comments for clarification):
from tutor import hooks
"""
Modify CMS OAuth configuration to prevent "Error: invalid_request. Mismatching redirect URI" when entering to Studio because Django Oauth Toolkit's request_uri is setted as https and we are trying to access as http.
An initial solution to this issue was to change Django Oauth Toolkit configuration directly in django admin, as suggested here https://discuss.openedx.org/t/error-invalid-request-mismatching-redirect-uri/7552 . But whenever we rebuild images or run "tutor local launch" this config is reseted and the issue reappears.
Changing SOCIAL_AUTH_REDIRECT_IS_HTTPS to True make this patch persistent and remove the need of changing django admin. See https://stackoverflow.com/a/56958260
"""
hooks.Filters.ENV_PATCHES.add_item(
(
"openedx-cms-common-settings",
"""
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PORT', '443')
USE_X_FORWARDED_PROTO = True
USE_X_FORWARDED_PORT = True
"""
)
)
hooks.Filters.ENV_PATCHES.add_item(
(
"openedx-lms-common-settings",
"""
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PORT', '443')
USE_X_FORWARDED_PROTO = True
USE_X_FORWARDED_PORT = True
"""
)
)
hey @yagouam, Thx for your response. I tried it, but unfortunately, it's always the same result...
Tutor does not support CMS urls that are suffixed with a port ("mydomain.com:4437") -- this issue is one of the reasons why.