SalesKing OmniAuth Strategy

If you are into omniAuth you can use this class to authenticate with SalesKing. Since every SK Account resides within its own subdomain, you need to set it before you want to use it.

You can use this file as a starting point because you might want to change the subdomain detection. If you find it useful and fiddled around with it, please let us know so we can enhance it.

Install

gem install sk_sdk

If you are using bundler add to Gemfile

gem "sk_sdk"
# or directly require used class
gem "sk_sdk", :require => "sk_sdk/omni_auth/salesking"

Usage

An initializers/omniauth.rb might look something like this:

# if you copied the file into your lib/
require File.expand_path('../../../lib/sk_auth', __FILE__)
# or from gem
require "sk_sdk/omni_auth/salesking"
begin
  sk = YAML.load_file(File.join(Rails.root, 'config', 'salesking.yml'))
  sk = sk[Rails.env]
rescue
  puts "Error reading config/salesking.yml please create and review this file"
end

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :salesking, sk['key'], sk['secret'], sk['url']
end

Copyright © 2011 Georg Leciejewski, released under the MIT license