Last active
January 26, 2024 14:35
-
-
Save maljukan/bd8d220500158a11706cd4756890b07b to your computer and use it in GitHub Desktop.
Django BaseOAuth2 workaround for setting the redirect_uri to localhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AzureADOAuth2v2(BaseOAuth2): | |
# Workaround for setting the redirect_uri to localhost. | |
# Host is set in proxy server.py and redirect_uri takes the request host value | |
def get_redirect_uri(self, state=None): | |
"""Build redirect with redirect_state parameter.""" | |
uri = self.redirect_uri | |
if self.REDIRECT_STATE and state: | |
uri = self.url_add_parameters(uri, {"redirect_state": state}) | |
if settings.DEBUG: | |
return uri.replace('127.0.0.1', 'localhost') | |
return uri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment