Add `Authorization` header support.
This commit is contained in:
parent
5fc546cf88
commit
fc46c60a81
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in New Issue