# Need help while Implementing SSO for dev environment

**URL:** https://meta.discourse.org/t/need-help-while-implementing-sso-for-dev-environment/302184
**Category:** SSO
**Tags:** dev-install
**Created:** [April 3, 2024, 5:35am UTC](https://meta.discourse.org/t/need-help-while-implementing-sso-for-dev-environment/302184 "2024-04-03T05:35:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kamlesh\_Joshi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kamlesh_joshi/32/375739_2.png) [@Kamlesh\_Joshi](https://meta.discourse.org/u/Kamlesh_Joshi)
#### Post date: [April 3, 2024, 5:35am UTC](https://meta.discourse.org/t/need-help-while-implementing-sso-for-dev-environment/302184/1 "2024-04-03T05:35:39Z")

</div>

I have setup discourse in my local machine and wanted to setup SSO login I can redirect the user when it clicks on login but when I get redirected I am continuously getting errors, I enabled logging also and it says  
`Nonce is incorrect, was generated in a different browser session, or has expired`  
Below is the python file which I’m using: [Discourse-setup/main.py at main · kamleshjoshi8102/Discourse-setup · GitHub](https://github.com/kamleshjoshi8102/Discourse-setup/blob/main/main.py)

Also Please note in my case it’s running on port 4201 so I have redirected to port 4201 on login

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [April 3, 2024, 3:47pm UTC](https://meta.discourse.org/t/need-help-while-implementing-sso-for-dev-environment/302184/2 "2024-04-03T15:47:48Z")

</div>

> [@Kamlesh\_Joshi](#):
>
> Nonce is incorrect, was generated in a different browser session, or has expired

This is the method that’s triggering the error:

```ruby
  def nonce_valid?
    if SiteSetting.discourse_connect_csrf_protection
      nonce && @secure_session[nonce_key].present?
    else
      nonce && Discourse.cache.read(nonce_key).present?
    end
  end

```

It’s checking that the nonce was generated by Discourse for the same session as as the one that redirects the user back to Discourse.

You could try setting the `discourse_connect_csrf_protection` site setting to `false`. Its default value is `true`. It’s a hidden site setting, so it can only be disabled from the Rails console.

When enabled, the `discourse_connect_csrf_protection` setting ensures that the entire SSO authentication process occurs through browser redirects. If you are starting the authentication process by making a background request to `session/sso`, you will need to disable it. More details here: [DiscourseConnect flow no longer functions - #5 by david](https://meta.discourse.org/t/discourseconnect-flow-no-longer-functions/182844/5).

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [May 3, 2024, 3:47pm UTC](https://meta.discourse.org/t/need-help-while-implementing-sso-for-dev-environment/302184/3 "2024-05-03T15:47:50Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
