omniauth-clio 0.0.2 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # OmniAuth clio
2
2
 
3
- 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!!
3
+ This gem contains the clio strategy for OmniAuth. I used the omniauth-twitter gem as a template to getting this up and running. Yay open source!!
4
4
 
5
- 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
5
+ 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
6
6
 
7
7
  ## How To Use It
8
8
 
@@ -14,43 +14,28 @@ 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` if using a rails app:
17
+ Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
18
18
 
19
19
  Rails.application.config.middleware.use OmniAuth::Builder do
20
- provider :clio, ENV['CLIO_CLIENT_KEY'], ENV['CLIO_CLIENT_SECRET']
20
+ provider :clio, "consumer_key", "consumer_secret"
21
21
  end
22
22
 
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['CLIO_CLIENT_KEY'], ENV['CLIO_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['CLIO_CLIENT_KEY'], ENV['CLIO_CLIENT_SECRET']
31
- end
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).
32
24
 
33
25
 
34
26
  ## Watch the RailsCast
35
27
 
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
28
+ Ryan Bates has put together an excellent RailsCast on OmniAuth:
45
29
 
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=...
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)
48
31
 
49
32
 
50
33
  ## Supported Rubies
51
34
 
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.
35
+ OmniAuth clio is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition.
53
36
 
37
+ [![CI Build
38
+ Status](https://secure.travis-ci.org/arunagw/omniauth-clio.png)](http://travis-ci.org/arunagw/omniauth-clio)
54
39
 
55
40
  ## Note on Patches/Pull Requests
56
41
 
@@ -58,11 +43,11 @@ OmniAuth clio is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition. I
58
43
  - Make your feature addition or bug fix.
59
44
  - Add tests for it. This is important so I don’t break it in a future version unintentionally.
60
45
  - 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)
61
- - Send me a pull request, thanks so much for your help!!
46
+ - Send me a pull request. Bonus points for topic branches.
62
47
 
63
48
  ## License
64
49
 
65
- Copyright (c) 2012 by Nicholas Shook
50
+ Copyright (c) 2011 by Nicholas Shook
66
51
 
67
52
  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:
68
53
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Clio
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -1,58 +1,68 @@
1
- require 'omniauth-oauth2'
1
+ require 'omniauth-oauth'
2
2
  require 'multi_json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
6
- class Clio < OmniAuth::Strategies::OAuth2
7
- option :name, "clio"
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}
8
11
 
9
- option :client_options, {
10
- :site => 'https://app.goclio.com',
11
- :authorize_url => '/oauth/authorize',
12
- :token_url => '/oauth/token'
13
- }
14
-
15
- uid { raw_info['id']}
12
+ uid { access_token.params[:user_id] }
16
13
 
17
14
  info do
18
15
  {
19
- :last_name => raw_info['user']['last_name']
20
- :first_name => raw_info['user']['first_name']
21
- :email => raw_info['user']['email']
22
- :firm => raw_info['account']['name']
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
+ }
23
25
  }
24
-
25
- def authorize_params
26
- super.tap do |params|
27
- params[:response_type] = "code"
28
- params[:client_id] = client.id
29
- params[:redirect_uri] ||= callback_url
30
- end
31
26
  end
32
27
 
33
- def request_phase
34
- super
28
+ extra do
29
+ { :raw_info => raw_info }
35
30
  end
36
31
 
37
- def build_access_token
38
- token_params = {
39
- :code => request.params['code'],
40
- :redirect_uri => callback_url,
41
- :client_id => client.id,
42
- :client_secret => client.secret,
43
- :grant_type => 'authorization_code'
44
- }
45
- client.get_token(token_params)
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
46
36
  end
47
37
 
48
- extra do
49
- {:raw_info => raw_info}
50
- end
38
+ alias :old_request_phase :request_phase
51
39
 
52
- def raw_info
53
- @raw_info ||= MultiJson.load(access_token.get('api/v1/users/who_am_i').body)
40
+ 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
54
64
  end
65
+
55
66
  end
56
67
  end
57
68
  end
58
-
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency 'multi_json', '~> 1.3'
22
- s.add_runtime_dependency 'omniauth-oauth2', '~> 1.0'
22
+ s.add_runtime_dependency 'omniauth-oauth', '~> 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,18 +1,21 @@
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('https://app.goclio.com')
14
+ subject.options.client_options.site.should eq('http://api-docs.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
17
20
  end
18
21
  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.2
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-09 00:00:00.000000000 Z
12
+ date: 2012-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.3'
30
30
  - !ruby/object:Gem::Dependency
31
- name: omniauth-oauth2
31
+ name: omniauth-oauth
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
@@ -114,7 +114,6 @@ executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files: []
116
116
  files:
117
- - .DS_Store
118
117
  - .gitignore
119
118
  - .rspec
120
119
  - .travis.yml
data/.DS_Store DELETED
Binary file