It’s possible that this issue is not related to Python, but more to do with how Auth and permissions are set up. Some things you can check:
Double-Check App Settings: Go through your app settings in the Shopify Partners dashboard to confirm the API key, whitelisted redirection URLs, and scopes.
URL Encoding: Ensure that the permission URL is correctly encoded, especially if your scopes or redirect URIs contain characters that need encoding.
Error Handling: Modify your app to handle and display errors during the OAuth process. This can provide more insight into where the process is failing.
Debugging: Use logging in your Django app to log the OAuth process, especially the part where your app receives the callback from Shopify. This can help identify if the issue is with the URL formation or with handling the callback.
Manual URL Construction: As a workaround, you can manually construct the install URL by appending the necessary scopes to it. It’s less elegant but can serve as a temporary solution and help to identify where the issue is.