Discourse doesn't redirect to return_sso_url after user logs in on private site

I’ve just tested this out with the WP Discourse plugin and using Discourse as the SSO Provider is working correctly for me on a private site. Users who are already logged into Discourse are automatically redirected back to the website. Users who are not logged into Discourse are redirect to the Discourse /login page. After clicking the Login button and entering their credentials, they are redirected back to the website.

You can see the WP Discourse implementation here: wp-discourse/lib/sso-client at main · discourse/wp-discourse · GitHub. The important part is how the payload is created: wp-discourse/lib/sso-client/query-redirect.php at main · discourse/wp-discourse · GitHub.

In the Discourse code, the difference between how logged in and non-logged in users is handled starts here: discourse/app/controllers/session_controller.rb at main · discourse/discourse · GitHub. A non-logged in user is redirected to /login with cookies[:sso_payload] set to the query string you sent from your django app. After being logged in, the sso_provider code should be being called again, with the payload set to the value of cookies[:sso_payload]. It seems that’s not happening for you.