認証サイトがユーザーのメール変更を許可する場合のDiscourse SSOの扱い方

Discourse の SSO フローを使用しており、このガイドに基づいて実装しています:Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)

これまで問題なく動作していましたが、システム内のユーザーがメールアドレスを変更できるようにしたところ、問題が発生するようになりました。

私のシステムでユーザーのメールアドレスを変更すると、Discourse への SSO が機能しなくなります。

ログインエラー

アカウントに問題があります。サイトの管理者にお問い合わせください。

Discourse がメールアドレスとユーザー名が一致しないペイロードを受け取り、どう処理すればよいか分からなくなっているのではないかと推測しています。

これをうまく処理する方法は何でしょうか?

私が考えた最善の案は、SSO を開始する前に Discourse API を使用して、Discourse 側のユーザーのメールアドレスをシステム内のものと一致させることです。

しかし、これが可能かどうかは分かりません。以下は私の失敗した試みです。

リクエスト内容:

https://forum-stage.{domain}.com/users/{username}/preferences/email

Headers:
Content-Type: application/x-www-form-urlencoded
Accept: application/json

Body (Postman で x-www-form-urlencoded 形式):
email: testemail@testdomain.com
api_key: 75a...77d
api_username: system

そして、受け取ったレスポンスは以下の通りです。

{
    "errors": [
        "You are not permitted to view the requested resource."
    ],
    "error_type": "invalid_access"
}
「いいね!」 1

I’m experiencing this too - did you ever figure out a way around this?

This should not be the case, we primarily key on the SSO id.

You can use the sync sso endpoint to sync the emails on Discourse side if you want to do so proactively but changing emails in your system should always work.

The one exception is

Discourse thinks SSO id is 5 email is bob@jane.com

You log in with SSO id of 6 email is bob@jane.com

This is not resolvable so you will need to manually intervene. (sync sso id 6 first)

「いいね!」 1