0Auth2 user linking within Discourse

Occasionally a user will experience an issue where each time they attempt to login they are asked to setup a new Discourse account. This commonly happens either on legacy accounts which are just now logging back into Discourse, or they signed up with username and password and are now trying to login as OAuth. In the past to resolve this, their Auth0 OAuth2 credentials need to be linked to their user ID in Discourse by running the below command from rails console within the discourse instance:

PluginStore.set('oauth2_basic', 'oauth2_basic_user_google-apps|tony.danza@aol.com', {"user_id":7235})

The problem seems to be this is no longer sticking, in fact it returns =>True where previously it would return Ok. I am at a pry prompt where in the past I didn’t think that was the case. When I exit Pry it also removes me from Rails Console.

Any idea what may be occurring here? Thanks!

Leveraging this plugin: GitHub - discourse/discourse-oauth2-basic: A basic OAuth2 plugin for use with Discourse

That command is outdated, now the plugin uses the user associations table.

1 Like

Can you share an example of the command that I will now run @Falco in replacement of it? Thank you for you help :bowing_man:

Following up for the latest command @Falco, thanks!

Any update or insight on the command @Falco?

This file shound give you an idea of how to construct the command you need:

1 Like

Sorry for the delay, I had to upgrade discourse before I tried again. I gave the change a shot but didn’t experience success. Below is the example of what I have since tried that return true.

[1] pry(main)> PluginStore.set('oauth2_basic', 'user_associated_accounts_google-apps|tony.danza@gmail.com', {"user_id":1234})
=> true