diff --git a/README.md b/README.md index b7e31d2..141f833 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ https://api.soundcloud.com/me?oauth_token=:token` The part with `:token` tells Discourse that it needs to replace that value with the authorization token it received when the authentication completed. +Discourse will also add the `Authorization: Bearer` HTTP header with the +token in case your API uses that instead. There is one last step to complete. We need to tell Discourse what attributes are available in the JSON it received. Here's a sample diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 8b13ba5..d9c8f30 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -10,4 +10,5 @@ en: oauth2_json_username_path: 'Path in the OAuth2 User JSON to the username. eg: user.username' oauth2_json_name_path: "Path in the OAuth2 User JSON to the user's full: user.name.full" oauth2_json_email_path: "Path in the OAuth2 User JSON to the user's email: user.email.primary" + oauth2_json_email_verified: "Check this if the OAuth2 site has verified the email" diff --git a/plugin.rb b/plugin.rb index 6d8070b..0c4a11c 100644 --- a/plugin.rb +++ b/plugin.rb @@ -43,7 +43,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).read) + user_json = JSON.parse(open(user_json_url, 'Authorization' => "Bearer #{token}" ).read) result = {} if user_json.present?