Configurando login X e rich embeds para Discourse

:bookmark: This guide explains how to set up Twitter login and rich embeds for your Discourse forum.

:person_raising_hand: Required user level: Administrator

:warning: In order for rich embeds to work properly, a Basic plan or higher for X Dev is mandatory. Rich embeds will not work with the Free X Dev plan.

X Configuration

  1. Go to the Developer Portal on X.

  2. Choose between a Free, Basic, or Pro X Dev plan and complete the developer agreement and policy requirements.

  3. After completing the agreement and policy requirements, you’ll be taken to the X dev dashboard.

Create a new project

  1. On your X Dev dashboard, click + Add Project.

  2. Complete the requested information:

    • Your project name
    • Use case. If you are using an account with a Basic or Pro plan, please select Embedding_Tweets_in_a_website.
    • Your project description (e.g., “Enable Twitter login and embeds on a Discourse forum”).
    • Select Production for the app environment. Note you may not be prompted to select the app environment.
    • Your app name
  3. You will be shown your API Key and API Key Secret. Please write these down so you can add them to your Discourse forum later.

  4. Click the App Settings button on the bottom right.

  5. Scroll down to the User Authentication Settings section and click the Set up button. Update the following fields:

    • App Permission → Read and enable Request_email_from_users
    • Type of App → Web App, Automated App or Bot
    • App info →
      • Callback URL / Redirect URL: https://yourdiscourseforum.com/auth/twitter/callback
      • Website URL: https://yourdiscourseforum.com
      • Terms of service: https://yourdiscourseforum.com/tos
      • Privacy Policy: https://yourdiscourseforum.com/privacy

  6. Click Save.

Discourse configuration

  1. Head over to your Discourse forum and enter the admin panel.

  2. Click the Settings button and choose Login to find the Twitter-related settings:

  3. Enable the enable_twitter_logins setting.

  4. Copy and paste the API Key from X into the twitter_consumer_key setting.

  5. Copy and Paste the API Key Secret from X into the twitter_consumer_secret setting.

  6. Click the green checkmark to save the changes.

Users should now be able to log into your forum using their Twitter Account.

Rich Embeds

The above steps also apply if you want to enable “rich embedding” which allows displaying tweets with their media (images video, etc). If you want rich embeds but don’t need Twitter login, simply uncheck enable twitter logins and leave the consumer key and secret intact.

:warning: Rebaking or rebuilding HTML for posts with tweets will re-fetch those tweets, counting against your monthly tweet cap.

Additional resources

Last edited by @sam 2026-03-18T04:43:33Z

Check documentPerform check on document:
75 curtidas

Note that the “Callback URL” field is now mandatory. If you omitted it in your setup, Twitter login will fail with a 403 unauthorized error.

Also note that if you have any extra spaces at the beginning or end of your callback urls, auth will fail. You can find other discussions about this change on the Twitter Community.

13 curtidas

Just noticed we were getting the same error on our site with Twitter auth. I noticed Twitter has a new process for authorizing developer apps, so we are going through the approval process. Not sure if it is related, or if this problem has just been in place for a long time now.

1 curtida

I setup my callback URL like this on Twitter, but still getting the same error.
https://www.helloforos.com/auth/twitter

Does this look like the right format? What do you guys use?

I’m going to try it again tomorrow in case there’s some caching issue with Twitter

Anyone else have success with Twitter login?

@charleswalter That callback url is wrong. It should be:

7 curtidas

that did the trick. Thx for calling that out.

I do recommend that those who haven’t applied on developer.twitter.com for their Twitter app, to do so.

For the near future, you can continue to manage existing apps here on apps.twitter.com. However, we will soon retire this site and consolidate all developer tools, API access, and app management within the developer portal at developer.twitter.com. You will be able to access and manage existing apps through that portal when we retire this site.

5 curtidas

March 2020

Guide completely rewritten because Twitter has changed the whole process … another time :sweat_smile:

16 curtidas

Twitter, não parece funcionar

Não é possível adicionar Criar um aplicativo

1 curtida

Funciona para mim

E, ao verificar https://api.twitterstat.us/, o Portal do Desenvolvedor está ok.

Você provavelmente está usando alguma extensão que bloqueia redes sociais, rastreamento ou algo similar. Tente fazer login em uma janela anônima com todas as extensões desativadas.

4 curtidas

O guia foi atualizado

7 curtidas

Espero que este seja o lugar certo para fazer essa pergunta. Vi em https://try.discourse.org/ que o registro via Twitter resulta na seguinte mensagem:

Este aplicativo poderá:

Ver tweets da sua linha do tempo (incluindo tweets protegidos), bem como suas listas e coleções.
Ver informações do seu perfil do Twitter e configurações da conta.
Ver as contas que você segue, silencia e bloqueia.
Ver seu endereço de e-mail.

É possível configurá-lo para acessar apenas a quantidade mínima de informações necessária — nome e endereço de e-mail, creio eu?

1 curtida

Isso já é a quantidade mínima de informações exigida pelo Twitter.

Como você pode ver no guia, a única coisa que exigimos do Twitter é o e-mail do usuário, necessário ao Discourse para criar a conta. Todo o resto são as configurações básicas decididas pelo Twitter ao selecionar “Apenas leitura” na seção de Permissões do Aplicativo.

7 curtidas

Oi, estou tentando incorporar uma resposta a um tweet.

A incorporação deve ficar assim.

Estou recebendo apenas a resposta. A mensagem original do tweet não aparece.
É assim que funciona no Discourse ou estou fazendo algo errado?

2 curtidas

Eu não uso o Twitter, mas imagino que o link de resposta seja diferente do link do tweet original. Portanto, você está apenas vinculando à resposta. Ao vincular ao tweet original, isso inclui também a primeira resposta ou apenas o tweet original?

1 curtida

Oi Jimpas,

Não, a ideia é que, se você incorporar a resposta, pode optar por ter o tweet original acima dela, como na imagem. Assim, a resposta tem contexto.
Eu também gosto bastante do estilo.

Estou apenas recebendo a resposta.
Uma solução alternativa são duas incorporações.

1 curtida

Isso é de fato uma solução alternativa. Mas como é possível escolher ter o tweet original acima de uma resposta? Então, como alguém “escolheria”? Às vezes vejo alguém postar em outro site que o tweet original tem a primeira resposta a ele. :thinking:

Estou notando o mesmo problema de registro. Quando tento usar uma conta de teste e o Twitter afirma no registro que o e-mail está sendo acessado, a conta de e-mail não é pré-preenchida no formulário de registro da conta após completar o handshake de autenticação com o Twitter, e também está mostrando “user_1” para o nome de usuário pré-preenchido. Rich embeds também não estão funcionando.

1 curtida

Não entre em pânico e espere pacientemente. A equipe do Discourse lê cada postagem com muito cuidado, então tenho certeza de que eles já estão cientes disso. :slight_smile:

2 curtidas

@Hifihedgehog e @dnfoz isso foi atribuído, nós o revisaremos em breve. Mais alguém está tendo problemas para configurar e fazer login?

4 curtidas

Alguma atualização?? Tenho o mesmo problema

1 curtida