omniauth-opinionage 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -21,7 +21,8 @@ Here's a quick example, adding the middleware to a Rails app in `config/initiali
21
21
 
22
22
  ```ruby
23
23
  Rails.application.config.middleware.use OmniAuth::Builder do
24
- provider :facebook, ENV['OPINIONAGE_KEY'], ENV['OPINIONAGE_SECRET']
24
+ provider :opinionage, ENV['OPINIONAGE_KEY'], ENV['OPINIONAGE_SECRET'],
25
+ :scope => "USER_BASIC_INFO"
25
26
  end
26
27
  ```
27
28
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Opinionage
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,26 +1,51 @@
1
1
  require 'omniauth-oauth2'
2
2
 
3
3
  module OmniAuth
4
+
4
5
  module Strategies
6
+
5
7
  class Opinionage < OmniAuth::Strategies::OAuth2
6
8
 
7
- option :client_options, { :site => "https://opinionage.com",
9
+ OAUTH_BASE_URL = "https://www.opinionage.com"
10
+ SERVICES_BASE_URL = "https://opinionage.com/api"
11
+
12
+ option :client_options, { :site => OAUTH_BASE_URL,
8
13
  :authorize_url => "/auth/authorize",
9
14
  :token_url => "/auth/token",
10
- }
15
+ :url => "https://opinionage.com", :ssl => { :verify => false } }
16
+
17
+ option :mode, :query
18
+ option :param_name, 'access_token'
11
19
 
12
20
  option :token_params, {
13
21
  :parse => :json
14
22
  }
15
23
 
16
- extra do
17
- {
18
- :credentials => {
19
- :access_token => access_token.token
20
- }
21
- }
24
+ uid { raw_info['user']['graph_id'] }
25
+
26
+ info do
27
+ user_info = raw_info['user']
28
+ if user_info
29
+ user_info.delete('id')
30
+ user_info.delete('graph_id')
31
+ user_info
32
+ else
33
+ { }
34
+ end
35
+ end
36
+
37
+ def raw_info
38
+ @raw_info ||= access_token.get(SERVICES_BASE_URL + "/1/users/me").parsed || { }
39
+ end
40
+
41
+ def build_access_token
42
+ verifier = request.params['code']
43
+ client.auth_code.get_token(verifier, { :redirect_uri => callback_url }.merge(token_params.to_hash(:symbolize_keys => true)), { :mode => :query,
44
+ :param_name => 'access_token' })
22
45
  end
23
46
 
24
47
  end
48
+
25
49
  end
50
+
26
51
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: omniauth-opinionage
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Carlo Alberto Degli Atti
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-08-07 00:00:00 Z
13
+ date: 2012-08-08 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: omniauth-oauth2