User qinyj reports an issue with the oauth2-basic plugin when attempting to log in via WeChat: the plugin expects a JSON response (application/json) but WeChat returns text/plain, causing authentication to fail. A screenshot shows successful Weibo login vs. failed WeChat login. qinyj provides a backtrace confirming the OAuth2 error. In post 7, qinyj offers a workaround for Chinese users: editing the oauth2 gem’s response.rb file to treat text/plain as :json — a fix specifically for WeChat, since it’s the only provider returning plain text. The user admits limited Ruby knowledge and seeks confirmation or official plugin updates.
Show Chinese compatriots a way forward. In the container /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/oauth2-1.4.7/lib/oauth2/response.rb, the following code exists:
# Content type assignments for various potential HTTP content types.
@@content_types = {
'application/json' => :json,
………………
'text/plain' => :text,
}
Change it to the following:
'text/plain' => :json,
Of course, this should only be useful for WeChat, as only WeChat returns text.