# Debug and fixing common DiscourseConnect issues

**URL:** https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496
**Category:** Integrations
**Tags:** sso, discourseconnect, how-to
**Created:** [December 4, 2018, 7:44pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496 "2018-12-04T19:44:22Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [December 4, 2018, 7:44pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/1 "2018-12-04T19:44:22Z")

</div>

As the administrator of a forum that is using [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true), you may occasionally get reports from users that when they attempt to login to the forum, they are greeted by an error message. For example: “There is a problem with your account. Please contact the site’s administrator.”

 ![20%20AM](https://global.discourse-cdn.com/meta/original/3X/3/c/3cbf977d351e17ff7404bb2f5e26565a3022d210.png)

### Enabling verbose [discourse connect](https://meta.discourse.org/t/13045?silent=true) logging

To debug the issue, the first thing you need to do is to enable the ‘verbose [discourse connect](https://meta.discourse.org/t/13045?silent=true) logging’ Site Setting on Discourse. If this setting was previously enabled, you can go directly to your site logs at Admin/Logs/Error Logs. If the setting was not previously enabled, you will need to ask the user to attempt logging in again so that you can generate a log entry of their failing login attempt.

### Reading the log entry

Go to Admin/Logs/Error Logs and look for a recent log entry that starts with `Verbose SSO log: Record was invalid`. If you have trouble finding the entry, enter ‘Record was invalid’ into the search box at the bottom of the logs page. Click on the log entry. Then click on the ‘info’ tab on the logs toolbar:

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/9/d/19d0f1a267e08ff4c375503e06087567b9ffd9f4.png)

The information that you will need is the reason (given in the log entry), and the `email` and `external_id` (found in the info section.)

### Solving require\_activation [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) login issues

A common issue with SSO login is: `Record was invalid: User {:primary_email=>"has already been taken"}`.

This can happen when the `require_activation` parameter in the SSO payload is set to `true` and the user has an existing account on Discourse that either does not yet have a `single_sign_on_record` associated with it, or has a `single_sign_on_record`, but the record’s `external_id` doesn’t match the `external_id` of the user who is trying to login.

To confirm this, enter your forum’s Rails console, and search for a user who has the email address that was used in the failed SSO login attempt:

```plaintext
u = User.find_by_email('sally@example.com')

```

Now, check if there is a `single_sign_on_record` for this user:

```plaintext
sso_record = u.single_sign_on_record

```

If the user exists on your forum, but does not have an SSO record, you can create a record for them using the values from the SSO log:

```plaintext
SingleSignOnRecord.create!(user_id: 2, external_id: 2, external_email: 'sally@example.com', last_payload: '')

```

The user should now be able to login.

If there is an existing SSO record for the user, but its `external_id` doesn’t match the `external_id` from the failed login attempt, you will need to look into why this has happened. One way this can happen is if a user’s account has been deleted and then recreated on the SSO provider site. In this case, you can update the SSO record to use the new `external_id`:

```plaintext
sso_record.external_id = <failed-sso-login-record-external_id>
sso_record.save!

```

The user should now be able to login.

If you are using the [WP Discourse](https://github.com/discourse/wp-discourse) plugin and running into the issue outlined above, see [Validate Email Addresses with the WP Discourse plugin](https://meta.discourse.org/t/how-to-validate-email-addresses-with-the-wp-discourse-plugin/130085) for details about how to resolve the issue without having to access the Rails console.

> Last edited by @JammyDodger 2024-05-26T07:21:30Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [January 18, 2019, 6:22pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/2 "2019-01-18T18:22:32Z")

</div>

> [@simon](#):
>
> enter your forum’s Rails console

I wasn’t sure how to enter the Rails console, but found the answer over [here](https://meta.discourse.org/t/how-to-get-into-rails-console/77310) and thought I’d publish for anyone else who doesn’t know how to get into the Rails console.

1. SSH into your site
2. Login as root user then do the following:
3. `sudo -s`
4. `cd /var/discourse/`
5. `ls`
6. `./launcher enter app`
7. `rails c`

That should get you into the Rails console!

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [January 18, 2019, 7:41pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/3 "2019-01-18T19:41:53Z")

</div>

> [@simon](#):
>
> If there is an existing SSO record for the user, but its `external_id` doesn’t match the `external_id` from the failed login attempt, you will need to look into why this has happened. One way this can happen is if a user’s account has been deleted and then recreated on the SSO provider site. In this case, you can update the SSO record to use the new `external_id` :
> 
> ```plaintext
> sso_record.external_id = <failed-sso-login-record-external_id>
> sso_record.save
> 
> ```

I was doing this and it was not working, but I finally got it to work when I replaced this:

```
sso_record.external_id = <failed-sso-login-record-external_id>

```

with this:

```
sso_record.external_id = 91

```

Where “91” was the external\_id of the user who was unable to login.

Thanks so much for this helpful discussion @simon! 🙌

---

<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: [January 18, 2019, 7:44pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/4 "2019-01-18T19:44:22Z")

</div>

> [@jord8on](#):
>
> I was doing this and it was not working, but I finally got it to work when I replaced this:
> 
> ```plaintext
> sso_record.external_id = <failed-sso-login-record-external_id>
> 
> ```
> 
> with this:
> 
> ```plaintext
> sso_record.external_id = 91
> 
> ```

Yes, `<failed-sso-login-record-external_id>` is meant to be replaced with the `external_id` from the log entry.

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [January 18, 2019, 8:58pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/5 "2019-01-18T20:58:32Z")

</div>

🤦‍♂️ I was trying it with the " \< \> " and it wasn’t working, of course ツ

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [May 31, 2019, 10:55pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/6 "2019-05-31T22:55:40Z")

</div>

Is there an easy way to reset the SSO ties for specific accounts with the Rails console? I have a couple admin accounts that are tied to different WP accounts than I would like because originally the email addresses didn’t match properly. Can I manually set them to be tied to a different WP account?

---

<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: [May 31, 2019, 11:06pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/7 "2019-05-31T23:06:41Z")

</div>

You can find the user’s WordPress ID by going to their user page from the WordPress dashboard. The user’s ID will be displayed in the address bar of your browser as the value of the `user_id` query parameter.

Once you have the user’s WordPress ID, you can update their SSO record on Discourse following the steps outlined for updating the `external_id` at the end of the ‘Solving require\_activation SSO login issues’ section of my original post. You need to be careful with this though - especially with admin accounts.

---

<div class="post-metadata">

### Author: ![peuplier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peuplier/32/157593_2.png) [@peuplier](https://meta.discourse.org/u/peuplier)
#### Post date: [September 25, 2019, 12:55am UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/8 "2019-09-25T00:55:09Z")

</div>

Hi, we tried these solutions but nothing worked… External id were the same and SSO is active. Do you have other solution please? I’m lost ☹

---

<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: [October 1, 2019, 6:36pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/9 "2019-10-01T18:36:42Z")

</div>

> [@peuplier](#):
>
> we tried these solutions but nothing worked

Is the problem with SSO login for a particular user, or is SSO not working at all on your site?

---

<div class="post-metadata">

### Author: ![peuplier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peuplier/32/157593_2.png) [@peuplier](https://meta.discourse.org/u/peuplier)
#### Post date: [October 1, 2019, 6:37pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/10 "2019-10-01T18:37:18Z")

</div>

only for a particular user

---

<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: [October 1, 2019, 6:41pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/11 "2019-10-01T18:41:17Z")

</div>

Make sure you have enabled the `verbose sso logging` site setting. If you have done that, are you able to find the error in your site’s logs when the user attempts to login? If you can share the error log here, we may be able to help. If there is data in the log that you don’t want to make public, you can send it to me in a PM.

---

<div class="post-metadata">

### Author: ![peuplier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peuplier/32/157593_2.png) [@peuplier](https://meta.discourse.org/u/peuplier)
#### Post date: [October 1, 2019, 6:48pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/12 "2019-10-01T18:48:02Z")

</div>

Does this help you? It is what you need?

It is the detail of the Log for member concerned by the situation (or at least, the only one that reported this problem)

Thank you so much!

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/7/a7784d21f347c54b4e886b60ce9554b7c873326d.png)

---

<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: [October 1, 2019, 7:05pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/13 "2019-10-01T19:05:06Z")

</div>

Thanks, that helps. It looks like your SSO provider site is a WordPress site. Are you using the [WP Discourse](https://github.com/discourse/wp-discourse) plugin for SSO? If so, and you are using the latest version of the plugin, try going to the user’s profile page and checking the ‘Email Address Verified’ checkbox. Then be sure to click the Save button. After doing this, have the user try logging in again.

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/5/c511c2aaeaf0f72494646c4476b5626d94731a33.png)

If you are not using the [WP Discourse](https://github.com/discourse/wp-discourse) plugin, we will need to give you more detailed instructions to fix the issue.

---

<div class="post-metadata">

### Author: ![peuplier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peuplier/32/157593_2.png) [@peuplier](https://meta.discourse.org/u/peuplier)
#### Post date: [October 1, 2019, 7:12pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/14 "2019-10-01T19:12:51Z")

</div>

You’re right, I’m using WordPress and I made the change, I will ask user to try again, thank you so much!! 😃

---

<div class="post-metadata">

### Author: ![peuplier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peuplier/32/157593_2.png) [@peuplier](https://meta.discourse.org/u/peuplier)
#### Post date: [October 2, 2019, 12:22pm UTC](https://meta.discourse.org/t/debug-and-fixing-common-discourseconnect-issues/103496/16 "2019-10-02T12:22:46Z")

</div>

It worked! Yeah! 😄 Thank you!
