omniauth-clio 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Binary file
data/README.md CHANGED
@@ -14,28 +14,43 @@ You can pull them in directly from github e.g.:
14
14
 
15
15
  gem 'omniauth-clio', :git => 'https://github.com/shicholas/omniauth-clio.git'
16
16
 
17
- Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
17
+ Once these are in, you need to add the following to your `config/initializers/omniauth.rb` if using a rails app:
18
18
 
19
19
  Rails.application.config.middleware.use OmniAuth::Builder do
20
- provider :clio, "consumer_key", "consumer_secret"
20
+ provider :clio, ENV['client_key'], ENV['client_secret']
21
21
  end
22
22
 
23
- You will obviously have to put in your key and secret, which you get when you register your app with clio (they call them API Key and Secret Key).
23
+ If you are using Devise in conjunction with omniauth, add this to your devise.rb file that is generated by devise:
24
+
25
+ config.omniauth :clio, ENV['client_key'], ENV['client_secret']
26
+
27
+
28
+ If you're just using something else that doesn't depend on Rack you can add this:
29
+ use OmniAuth::Builder do
30
+ provider :cheddar, ENV['client_key'], ENV['client_secret']
31
+ end
24
32
 
25
33
 
26
34
  ## Watch the RailsCast
27
35
 
28
- Ryan Bates has put together an excellent RailsCast on OmniAuth:
36
+ Ryan Bates has put together an excellent RailsCast on OmniAuth which you can watch here: http://railscasts.com/episodes/241-simple-omniauth-revised
37
+
38
+ ## Getting your API Key
39
+ 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.
40
+
41
+ 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:
42
+ export CLIO_CLIENT_KEY=...
43
+ export CLIO_CLIENT_SECRET=...
44
+ rails server
29
45
 
30
- [![RailsCast #241](https://www.evernote.com/shard/s35/sh/479f2503-aefa-4542-a7b4-8f84fd22eafc/0571f5a3795a0be3d0b0814312a8d5b7/res/49b5478a-657c-4aff-ae58-dae08b9a46d5/Screen_Shot_2012-07-15_at_12.41.15_PM-20120715-125424.jpg.jpg "RailsCast #241 - Simple OmniAuth (revised)")](http://railscasts.com/episodes/241-simple-omniauth-revised)
46
+ If you love Heroku as much as I do, you can use these commands to get it to work there:
47
+ heroku config:add CLIO_APP_KEY=...
31
48
 
32
49
 
33
50
  ## Supported Rubies
34
51
 
35
- OmniAuth clio is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition.
52
+ 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.
36
53
 
37
- [![CI Build
38
- Status](https://secure.travis-ci.org/arunagw/omniauth-clio.png)](http://travis-ci.org/arunagw/omniauth-clio)
39
54
 
40
55
  ## Note on Patches/Pull Requests
41
56
 
@@ -43,11 +58,11 @@ Status](https://secure.travis-ci.org/arunagw/omniauth-clio.png)](http://travis-c
43
58
  - Make your feature addition or bug fix.
44
59
  - Add tests for it. This is important so I don’t break it in a future version unintentionally.
45
60
  - 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)
46
- - Send me a pull request. Bonus points for topic branches.
61
+ - Send me a pull request, thanks so much for your help!!
47
62
 
48
63
  ## License
49
64
 
50
- Copyright (c) 2011 by Nicholas Shook
65
+ Copyright (c) 2012 by Nicholas Shook
51
66
 
52
67
  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:
53
68
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Clio
3
- VERSION = "0.0.12"
3
+ VERSION = "0.0.13"
4
4
  end
5
5
  end
@@ -1,68 +1,39 @@
1
- require 'omniauth-oauth'
2
- require 'multi_json'
1
+ require 'omniauth-oauth2'
2
+ # require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- class Clio < OmniAuth::Strategies::OAuth
7
- option :name, 'clio'
8
- option :client_options, {:authorize_path => '/oauth/authenticate',
9
- :site => 'http://api-docs.goclio.com/',
10
- :proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil}
11
-
12
- uid { access_token.params[:user_id] }
13
-
14
- info do
15
- {
16
- :nickname => raw_info['screen_name'],
17
- :name => raw_info['name'],
18
- :location => raw_info['location'],
19
- :image => raw_info['profile_image_url'],
20
- :description => raw_info['description'],
21
- :urls => {
22
- 'Website' => raw_info['url'],
23
- 'clio' => 'http://goclio.com/' + raw_info['screen_name'],
24
- }
25
- }
26
- end
27
-
28
- extra do
29
- { :raw_info => raw_info }
30
- end
31
-
32
- def raw_info
33
- @raw_info ||= MultiJson.load(access_token.get('/1/account/verify_credentials.json').body)
34
- rescue ::Errno::ETIMEDOUT
35
- raise ::Timeout::Error
6
+ class Clio < OmniAuth::Strategies::OAuth2
7
+ option :name, "Clio"
8
+
9
+ option :client_options, {
10
+ :site => 'https://app.goclio.com',
11
+ :authorize_url => '/oauth/authorize',
12
+ :token_url => '/oauth/access_token'
13
+ }
14
+
15
+ def authorize_params
16
+ super.tap do |params|
17
+ params[:response_type] = "code"
18
+ params[:client_id] = client.id
19
+ params[:redirect_uri] ||= callback_url
20
+ end
36
21
  end
37
22
 
38
- alias :old_request_phase :request_phase
39
-
40
23
  def request_phase
41
- force_login = session['omniauth.params'] ? session['omniauth.params']['force_login'] : nil
42
- screen_name = session['omniauth.params'] ? session['omniauth.params']['screen_name'] : nil
43
- x_auth_access_type = session['omniauth.params'] ? session['omniauth.params']['x_auth_access_type'] : nil
44
- if force_login && !force_login.empty?
45
- options[:authorize_params] ||= {}
46
- options[:authorize_params].merge!(:force_login => 'true')
47
- end
48
- if screen_name && !screen_name.empty?
49
- options[:authorize_params] ||= {}
50
- options[:authorize_params].merge!(:force_login => 'true', :screen_name => screen_name)
51
- end
52
- if x_auth_access_type
53
- options[:request_params] || {}
54
- options[:request_params].merge!(:x_auth_access_type => x_auth_access_type)
55
- end
56
-
57
- if session['omniauth.params'] && session['omniauth.params']["use_authorize"] == "true"
58
- options.client_options.authorize_path = '/oauth/authorize'
59
- else
60
- options.client_options.authorize_path = '/oauth/authenticate'
61
- end
62
-
63
- old_request_phase
24
+ super
64
25
  end
65
26
 
27
+ def build_access_token
28
+ token_params = {
29
+ :code => request.params['code'],
30
+ :redirect_uri => callback_url,
31
+ :client_id => client.id,
32
+ :client_secret => client.secret,
33
+ :grant_type => 'authorization_code'
34
+ }
35
+ client.get_token(token_params)
36
+ end
66
37
  end
67
38
  end
68
39
  end
@@ -18,8 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency 'multi_json', '~> 1.3'
22
- s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
21
+ # s.add_dependency 'multi_json', '~> 1.3'
22
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.0'
23
23
  s.add_development_dependency 'rspec', '~> 2.7'
24
24
  s.add_development_dependency 'rack-test'
25
25
  s.add_development_dependency 'simplecov'
@@ -1,21 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe OmniAuth::Strategies::clio do
3
+ describe OmniAuth::Strategies::Clio do
4
4
  subject do
5
- OmniAuth::Strategies::clio.new({})
5
+ OmniAuth::Strategies::Clio.new({})
6
6
  end
7
7
 
8
8
  context "client options" do
9
9
  it 'should have correct name' do
10
- subject.options.name.should eq("clio")
10
+ subject.options.name.should eq("Clio")
11
11
  end
12
12
 
13
13
  it 'should have correct site' do
14
- subject.options.client_options.site.should eq('http://api-docs.goclio.com')
14
+ subject.options.client_options.site.should eq('https://app.goclio.com')
15
15
  end
16
16
 
17
- it 'should have correct authorize url' do
18
- subject.options.client_options.authorize_path.should eq('/oauth/authenticate')
19
- end
20
17
  end
21
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-clio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,26 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: multi_json
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.3'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '1.3'
30
- - !ruby/object:Gem::Dependency
31
- name: omniauth-oauth
15
+ name: omniauth-oauth2
32
16
  requirement: !ruby/object:Gem::Requirement
33
17
  none: false
34
18
  requirements:
@@ -114,6 +98,7 @@ executables: []
114
98
  extensions: []
115
99
  extra_rdoc_files: []
116
100
  files:
101
+ - .DS_Store
117
102
  - .gitignore
118
103
  - .rspec
119
104
  - .travis.yml