lib/omniauth/strategies/protons.rb in omniauth-protons-0.2.2 vs lib/omniauth/strategies/protons.rb in omniauth-protons-0.4
- old
+ new
@@ -1,7 +1,10 @@
require 'omniauth/strategies/oauth2'
+MAIN_DOMAIN = Rails.env.development? ? 'http://8protons.dev' : 'https://8protons.com'
+API_DOMAIN = Rails.env.development? ? 'http://api8p.com' : 'https://api8p.com'
+
module OmniAuth
module Strategies
# Authentication strategy for connecting with APIs constructed using
# the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10).
# You must generally register your application with the provider and
@@ -10,26 +13,34 @@
class Protons < OmniAuth::Strategies::OAuth2
# change the class name and the :name option to match your application name
option :name, :protons
option :client_options, {
- :site => Rails.env.development? ? "http://8protons.dev" : "https://8protons.com",
- :authorize_url => "/oauth/authorize"
+ site: MAIN_DOMAIN,
+ token_url: "#{API_DOMAIN}/oauth2/tokens",
+ #authorize_url: '/oauth/auth'
}
- uid { raw_info["id"] }
+ uid { raw_info['id'] }
info do
{
- :name => raw_info["display_name"],
- :email => raw_info["email"],
- :nickname => raw_info["username"]
+ name: raw_info['fields']['display_name'],
+ email: raw_info['fields']['email'],
+ nickname: raw_info['fields']['username']
+ #:gravatar_hash => raw_info['fields']['gravatar_hash']
# and anything else you want to return to your API consumers
}
end
+ extra do
+ {
+ 'raw_info' => raw_info
+ }
+ end
+
def raw_info
- @raw_info ||= access_token.get('/api/users/me.json').parsed
+ @raw_info ||= access_token.get("#{API_DOMAIN}/base/me").parsed
end
end # Protons
end
end
\ No newline at end of file