This gem contains the clio strategy for OmniAuth. I used the omniauth-harvest gem as a template to getting this up and running. Yay open source!!
Clio uses the OAuth 2.0 flow, you can read about it here: http://api-docs.goclio.com/v1/index.html#authorization-with-oauth-2-0
Usage is as per any other OmniAuth 2.0 strategy. So let's say you're using Rails, you need to add the strategy to your Gemfile
:
gem 'omniauth-clio'
You can pull them in directly from github e.g.:
gem 'omniauth-clio', :git => 'https://github.com/shicholas/omniauth-clio.git'
Once these are in, you need to add the following to your config/initializers/omniauth.rb
if using a rails app:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :clio, ENV['CLIO_CLIENT_KEY'], ENV['CLIO_CLIENT_SECRET']
end
If you are using Devise in conjunction with omniauth, add this to your devise.rb file that is generated by devise:
config.omniauth :clio, ENV['CLIO_CLIENT_KEY'], ENV['CLIO_CLIENT_SECRET']
If you're just using something else that doesn't depend on Rack you can add this: use OmniAuth::Builder do provider :cheddar, ENV['CLIO_CLIENT_KEY'], ENV['CLIO_CLIENT_SECRET'] end
Ryan Bates has put together an excellent RailsCast on OmniAuth which you can watch here: http://railscasts.com/episodes/241-simple-omniauth-revised
To get an API Key from Clio you will need to follow these steps http://api-docs.goclio.com/v1/index.html#create-a-clio-account.
It is recommended you use environment variables to store your keys so that Clio can regonize your app. You can do so by using these shell commands: export CLIO_CLIENT_KEY=... export CLIO_CLIENT_SECRET=... rails server
If you love Heroku as much as I do, you can use these commands to get it to work there: heroku config:add CLIO_APP_KEY=...
OmniAuth clio is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition. I used the simplecov gem, https://github.com/colszowka/simplecov, to help me determine this.
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request, thanks so much for your help!!
Copyright (c) 2012 by Nicholas Shook
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.