From ec1b82c64dbda66298226f06ca2b1427f6c70209 Mon Sep 17 00:00:00 2001 From: pablo Date: Fri, 5 Jun 2015 19:16:02 -0300 Subject: [PATCH 1/2] User info url is an additional option --- lib/omniauth/strategies/wordpress.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/omniauth/strategies/wordpress.rb b/lib/omniauth/strategies/wordpress.rb index 57ab0d8..b213cc7 100644 --- a/lib/omniauth/strategies/wordpress.rb +++ b/lib/omniauth/strategies/wordpress.rb @@ -6,7 +6,8 @@ class OmniAuth::Strategies::Wordpress < OmniAuth::Strategies::OAuth2 option :client_options, { :site => "https://public-api.wordpress.com", :authorize_url => 'https://public-api.wordpress.com/oauth2/authorize', - :token_url => 'https://public-api.wordpress.com/oauth2/token' + :token_url => 'https://public-api.wordpress.com/oauth2/token', + :user_url => '/oauth/me' } option :token_params, { @@ -33,10 +34,12 @@ class OmniAuth::Strategies::Wordpress < OmniAuth::Strategies::OAuth2 end def raw_info - @raw_info ||= MultiJson.decode(access_token.get('/rest/v1/me').body) - rescue ::Errno::ETIMEDOUT - raise ::Timeout::Error - end + response = access_token.get(client.options['user_url']) + @raw_info ||= MultiJson.decode(response.body) + rescue MultiJson::ParseError + error = ::OAuth2::Error.new(response) + fail(error, "Could not parse response from user url") + rescue ::Errno::ETIMEDOUT + raise ::Timeout::Error + end end - - From 17186915aa4463e8f251ea82a858343036b4dac8 Mon Sep 17 00:00:00 2001 From: pablo Date: Wed, 24 Jun 2015 19:06:33 -0300 Subject: [PATCH 2/2] fixed: string should have been symbol --- lib/omniauth/strategies/wordpress.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/omniauth/strategies/wordpress.rb b/lib/omniauth/strategies/wordpress.rb index b213cc7..99388e4 100644 --- a/lib/omniauth/strategies/wordpress.rb +++ b/lib/omniauth/strategies/wordpress.rb @@ -34,7 +34,7 @@ class OmniAuth::Strategies::Wordpress < OmniAuth::Strategies::OAuth2 end def raw_info - response = access_token.get(client.options['user_url']) + response = access_token.get(client.options[:user_url]) @raw_info ||= MultiJson.decode(response.body) rescue MultiJson::ParseError error = ::OAuth2::Error.new(response)