Here is another patch set that does not create a new dependency. Thank you to Tubbo, Dsimon and Fox_Mulder_CP for their help on #rubyonrails. The same questions of how best to integrate this apply.
diff --git a/plugin.rb b/plugin.rb
index 2eca4db..feed336 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -4,6 +4,9 @@
# authors: Robin Ward
require_dependency 'auth/oauth2_authenticator.rb'
+require 'net/http'
+require 'uri'
+
enabled_site_setting :oauth2_enabled
@@ -50,7 +53,7 @@ class OAuth2BasicAuthenticator < ::Auth::OAuth2Authenticator
def fetch_user_details(token)
user_json_url = SiteSetting.oauth2_user_json_url.sub(':token', token)
- user_json = JSON.parse(open(user_json_url, 'Authorization' => "Bearer #{tok
+ user_json = JSON.parse(Net::HTTP.post_form(URI(user_json_url), {'Authorization' => "Bearer #{token}"} ).body)
result = {}
if user_json.present?
tarek : )