How to generate nonce from client-side Javascript

In case anyone else finds this, I followed @fefrei’s advice

  1. Identify that the user has logged into your site
  2. Identify that the user is not currently logged into discourse
  3. Send the user to discourse’s /session/sso page which will trigger the sso with the nonce
  4. The SSO endpoint that gets the call from discourse recognizes it needs to do things automatically
  5. Log the user in and provide the necessary information back to discourse to complete the flow

Its not pretty (causes the screen to flash) but it works. Thanks :+1: