Remove duplicate configuration value in lib/josh_id.rb.
authorWard Vandewege <ward@clinicalfuture.com>
Fri, 25 Jan 2013 18:50:12 +0000 (13:50 -0500)
committerWard Vandewege <ward@clinicalfuture.com>
Fri, 25 Jan 2013 18:50:12 +0000 (13:50 -0500)
CUSTOM_PROVIDER_URL is now only defined in
config/initializers/omniauth.rb

config/initializers/omniauth.rb.example
lib/josh_id.rb

index b75a76e2b057bd881d788410178b712f6da9025e..e7025545a16dd573e091c98691fdcc4294bc51c0 100644 (file)
@@ -7,5 +7,5 @@ APP_SECRET = rand(2**512).to_s(36) # CHANGE ME!
 CUSTOM_PROVIDER_URL = 'http://auth.clinicalfuture.com'
 
 Rails.application.config.middleware.use OmniAuth::Builder do
-  provider :josh_id, APP_ID, APP_SECRET
+  provider :josh_id, APP_ID, APP_SECRET, CUSTOM_PROVIDER_URL
 end
index 31fba2265785ed4a5261fd6af7c85298f0b6c10f..25656a978129c7dde1c8278a6db1df2f09687d1d 100644 (file)
@@ -3,16 +3,14 @@ module OmniAuth
   module Strategies
     class JoshId < OmniAuth::Strategies::OAuth2
 
-      CUSTOM_PROVIDER_URL = 'http://auth.clinicalfuture.com'
+      args [:client_id, :client_secret, :custom_provider_url]
 
-      option :client_options, {
-        :site =>  CUSTOM_PROVIDER_URL,
-        :authorize_url => "#{CUSTOM_PROVIDER_URL}/auth/josh_id/authorize",
-        :access_token_url => "#{CUSTOM_PROVIDER_URL}/auth/josh_id/access_token"
-      }
+      option :custom_provider_url, ''
 
       uid { raw_info['id'] }
 
+      option :client_options, {}
+
       info do
         {
           :first_name => raw_info['info']['first_name'],
@@ -28,6 +26,13 @@ module OmniAuth
         }
       end
       
+      def client
+        options.client_options[:site] = options[:custom_provider_url]
+        options.client_options[:authorize_url] = "#{options[:custom_provider_url]}/auth/josh_id/authorize"
+        options.client_options[:access_token_url] = "#{options[:custom_provider_url]}/auth/josh_id/access_token"
+        ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
+      end
+
       def callback_url
         full_host + script_name + callback_path + query_string
       end