Utilizzando il plugin OAuth2 Basic Support (incluso nel nucleo di Discourse dalla versione v2025.11.0), è possibile configurare l’autenticazione Salesforce.
Per farlo, crea un’app OAuth2 connessa su Salesforce:
Crea → App → Nuova app connessa
Assicurati di consentire l’accesso a “accesso alle informazioni di base”
Imposta l’URL di callback su https://TUOFORUM.COM/auth/oauth2_basic/callback: Nota che il forum Discourse deve essere eseguito con HTTPS.
Prendi nota dell’ID client e della chiave segreta
Sul lato Discourse, configura le seguenti impostazioni (trovabili in Amministratore > Accesso > OAuth2.0):
oauth2 abilitato: true
oauth2 client id e secret, come indicato nella sezione precedente
Thanks for this post, which was invaluable in setting up a recent project, which required Salesforce login.
In our case, the Salesforce app was a Community, which meant we had to change some of the details above. I’m posting on this old thread in case it helps anyone else. It nearly broke my brain for a whole day.
However we still had problems with 403 Forbidden errors, which were plain unstyled HTML and didn’t look very much like a Discourse error to me, which led to much debugging of Salesforce and gnashing of teeth. But the problem was in Discourse.
Forbidden
You don’t have permission to access this resource.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Although the redirect to Callback URL seemed to be working, the browser console registered authentication failures. In the end it was the unsetoauth2 callback user id path which was the cause of the authentication failure. Setting it to id fixed everything.
Grazie per le linee guida. Siamo riusciti ad autenticarci con successo tramite Salesforce, ma abbiamo riscontrato un problema. Sembra che i nostri oggetti/campi di SF non vengano trasmessi correttamente a Discourse. Immediatamente dopo un login riuscito in SF su Discourse, quest’ultimo sembra trattarlo come un nuovo utente e richiede nome utente, email e nome, anche se questi dovrebbero provenire dai campi name, email e username del JSON OAuth2.
Possiamo chiedere aiuto per conoscere il formato JSON degli oggetti/campi di SF utilizzati nel plugin OAuth2? Abbiamo provato object.field, object_field e semplicemente field. Non sembra generare errori, ma nulla viene comunque trasmesso da SF a Discourse tramite JSON per riconoscere il login come non un nuovo utente di Discourse.
Solo un aggiornamento: abbiamo trovato una soluzione al nostro problema, configurando queste impostazioni sul nostro lato per mappare i campi di Salesforce.
È necessario impostare quanto segue:
### oauth2 fetch user details - **spuntato**
### oauth2 user json url - **https://<yoursfsite.com>/services/oauth2/userinfo**
### oauth2 user json url method - **get**
### oauth2 json user id path - **user_id**
### oauth2 json username path - **preferred_username**
### oauth2 json name path - **name**
### oauth2 json email path - **email**
Speriamo che questo aiuti altri che cercano una soluzione per la connessione oauth2 a Salesforce.