fb_graph 2.4.10 → 2.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/fb_graph/auth.rb +2 -2
- data/lib/fb_graph/exception.rb +12 -0
- data/spec/fb_graph/auth_spec.rb +59 -6
- metadata +82 -133
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fb_graph (2.4.
|
4
|
+
fb_graph (2.4.10)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
6
|
rack-oauth2 (>= 0.14.4)
|
7
7
|
tzinfo
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
addressable (2.2.7)
|
29
29
|
attr_required (0.0.5)
|
30
30
|
builder (3.0.0)
|
31
|
-
configatron (2.9.
|
31
|
+
configatron (2.9.1)
|
32
32
|
yamler (>= 0.1.0)
|
33
33
|
cover_me (1.2.0)
|
34
34
|
configatron
|
@@ -42,7 +42,7 @@ GEM
|
|
42
42
|
i18n (0.6.0)
|
43
43
|
journey (1.0.3)
|
44
44
|
json (1.6.6)
|
45
|
-
multi_json (1.2
|
45
|
+
multi_json (1.3.2)
|
46
46
|
rack (1.4.1)
|
47
47
|
rack-cache (1.2)
|
48
48
|
rack (>= 0.4)
|
@@ -61,7 +61,7 @@ GEM
|
|
61
61
|
rspec-expectations (~> 2.9.0)
|
62
62
|
rspec-mocks (~> 2.9.0)
|
63
63
|
rspec-core (2.9.0)
|
64
|
-
rspec-expectations (2.9.
|
64
|
+
rspec-expectations (2.9.1)
|
65
65
|
diff-lcs (~> 1.1.3)
|
66
66
|
rspec-mocks (2.9.0)
|
67
67
|
sprockets (2.1.2)
|
@@ -69,8 +69,8 @@ GEM
|
|
69
69
|
rack (~> 1.0)
|
70
70
|
tilt (~> 1.1, != 1.3.0)
|
71
71
|
tilt (1.3.3)
|
72
|
-
tzinfo (0.3.
|
73
|
-
webmock (1.8.
|
72
|
+
tzinfo (0.3.33)
|
73
|
+
webmock (1.8.6)
|
74
74
|
addressable (>= 2.2.7)
|
75
75
|
crack (>= 0.1.7)
|
76
76
|
yamler (0.1.0)
|
data/README.rdoc
CHANGED
@@ -231,7 +231,7 @@ See more here: http://developers.facebook.com/docs/authentication/fb_sig/
|
|
231
231
|
|
232
232
|
# in callback
|
233
233
|
client.authorization_code = params[:code]
|
234
|
-
access_token = client.access_token!
|
234
|
+
access_token = client.access_token! :client_auth_body # => Rack::OAuth2::AccessToken
|
235
235
|
FbGraph::User.me(access_token).fetch # => FbGraph::User
|
236
236
|
|
237
237
|
==== Session Key Exchange
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.11
|
data/lib/fb_graph/auth.rb
CHANGED
@@ -56,7 +56,7 @@ module FbGraph
|
|
56
56
|
self.access_token = client.access_token! :client_auth_body
|
57
57
|
self
|
58
58
|
rescue Rack::OAuth2::Client::Error => e
|
59
|
-
|
59
|
+
Exception.handle_rack_oauth2_error e
|
60
60
|
end
|
61
61
|
|
62
62
|
private
|
@@ -69,7 +69,7 @@ module FbGraph
|
|
69
69
|
self.user = User.new(data[:user_id], :access_token => access_token)
|
70
70
|
self
|
71
71
|
rescue Rack::OAuth2::Client::Error => e
|
72
|
-
|
72
|
+
Exception.handle_rack_oauth2_error e
|
73
73
|
end
|
74
74
|
|
75
75
|
def build_access_token(data)
|
data/lib/fb_graph/exception.rb
CHANGED
@@ -66,6 +66,18 @@ module FbGraph
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def self.handle_rack_oauth2_error(e)
|
70
|
+
exception = case e.status
|
71
|
+
when 400
|
72
|
+
BadRequest.new(e.message)
|
73
|
+
when 401
|
74
|
+
Unauthorized.new(e.message)
|
75
|
+
else
|
76
|
+
Exception.new(e.status, e.message)
|
77
|
+
end
|
78
|
+
raise exception
|
79
|
+
end
|
80
|
+
|
69
81
|
def initialize(code, message, body = '')
|
70
82
|
@code = code
|
71
83
|
if body.present?
|
data/spec/fb_graph/auth_spec.rb
CHANGED
@@ -106,11 +106,33 @@ describe FbGraph::Auth do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'when Rack::OAuth2::Client::Error occurred' do
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
context 'when BadRequest' do
|
110
|
+
it 'should raise FbGraph::BadRequest' do
|
111
|
+
mock_graph :post, 'oauth/access_token', 'blank', :status => [400, 'BadRequest'] do
|
112
|
+
lambda do
|
113
|
+
auth.from_cookie(cookie)
|
114
|
+
end.should raise_exception FbGraph::BadRequest
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when Unauthorized' do
|
120
|
+
it 'should raise FbGraph::Unauthorized' do
|
121
|
+
mock_graph :post, 'oauth/access_token', 'blank', :status => [401, 'Unauthorized'] do
|
122
|
+
lambda do
|
123
|
+
auth.from_cookie(cookie)
|
124
|
+
end.should raise_exception FbGraph::Unauthorized
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'otherwise' do
|
130
|
+
it 'should raise FbGraph::Exception' do
|
131
|
+
mock_graph :post, 'oauth/access_token', 'blank', :status => [403, 'Forbidden'] do
|
132
|
+
lambda do
|
133
|
+
auth.from_cookie(cookie)
|
134
|
+
end.should raise_exception FbGraph::Exception
|
135
|
+
end
|
114
136
|
end
|
115
137
|
end
|
116
138
|
end
|
@@ -166,11 +188,42 @@ describe FbGraph::Auth do
|
|
166
188
|
it 'should get new token' do
|
167
189
|
mock_graph :post, '/oauth/access_token', 'token_with_expiry' do
|
168
190
|
auth.exchange_token! 'old_token'
|
169
|
-
puts auth.access_token
|
170
191
|
auth.access_token.access_token.should == 'new_token'
|
171
192
|
auth.access_token.expires_in.should == 3600
|
172
193
|
end
|
173
194
|
end
|
195
|
+
|
196
|
+
context 'when Rack::OAuth2::Client::Error occurred' do
|
197
|
+
context 'when BadRequest' do
|
198
|
+
it 'should raise FbGraph::BadRequest' do
|
199
|
+
mock_graph :post, 'oauth/access_token', 'blank', :status => [400, 'BadRequest'] do
|
200
|
+
lambda do
|
201
|
+
auth.exchange_token! 'old_token'
|
202
|
+
end.should raise_exception FbGraph::BadRequest
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'when Unauthorized' do
|
208
|
+
it 'should raise FbGraph::Unauthorized' do
|
209
|
+
mock_graph :post, 'oauth/access_token', 'blank', :status => [401, 'Unauthorized'] do
|
210
|
+
lambda do
|
211
|
+
auth.exchange_token! 'old_token'
|
212
|
+
end.should raise_exception FbGraph::Unauthorized
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'otherwise' do
|
218
|
+
it 'should raise FbGraph::Exception' do
|
219
|
+
mock_graph :post, 'oauth/access_token', 'blank', :status => [403, 'Forbidden'] do
|
220
|
+
lambda do
|
221
|
+
auth.exchange_token! 'old_token'
|
222
|
+
end.should raise_exception FbGraph::Exception
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
174
227
|
end
|
175
228
|
end
|
176
229
|
|
metadata
CHANGED
@@ -1,155 +1,112 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.11
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 4
|
9
|
-
- 10
|
10
|
-
version: 2.4.10
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- nov matake
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: httpclient
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70120463031880 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 123
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 2
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 2.2.0.2
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rack-oauth2
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70120463031880
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rack-oauth2
|
27
|
+
requirement: &70120458748700 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 47
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 14
|
49
|
-
- 4
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 0.14.4
|
51
33
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: tzinfo
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *70120458748700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: tzinfo
|
38
|
+
requirement: &70120458748320 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
65
44
|
type: :runtime
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rake
|
69
45
|
prerelease: false
|
70
|
-
|
46
|
+
version_requirements: *70120458748320
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70120458747780 !ruby/object:Gem::Requirement
|
71
50
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
- 8
|
79
|
-
version: "0.8"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.8'
|
80
55
|
type: :development
|
81
|
-
version_requirements: *id004
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: rcov
|
84
56
|
prerelease: false
|
85
|
-
|
57
|
+
version_requirements: *70120458747780
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: cover_me
|
60
|
+
requirement: &70120458747260 !ruby/object:Gem::Requirement
|
86
61
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
- 9
|
94
|
-
version: "0.9"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.2.0
|
95
66
|
type: :development
|
96
|
-
version_requirements: *id005
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec
|
99
67
|
prerelease: false
|
100
|
-
|
68
|
+
version_requirements: *70120458747260
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &70120458746800 !ruby/object:Gem::Requirement
|
101
72
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
segments:
|
107
|
-
- 2
|
108
|
-
version: "2"
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2'
|
109
77
|
type: :development
|
110
|
-
version_requirements: *id006
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: webmock
|
113
78
|
prerelease: false
|
114
|
-
|
79
|
+
version_requirements: *70120458746800
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: webmock
|
82
|
+
requirement: &70120458746340 !ruby/object:Gem::Requirement
|
115
83
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
hash: 11
|
120
|
-
segments:
|
121
|
-
- 1
|
122
|
-
- 6
|
123
|
-
- 2
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
124
87
|
version: 1.6.2
|
125
88
|
type: :development
|
126
|
-
version_requirements: *id007
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: actionpack
|
129
89
|
prerelease: false
|
130
|
-
|
90
|
+
version_requirements: *70120458746340
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: actionpack
|
93
|
+
requirement: &70120458745880 !ruby/object:Gem::Requirement
|
131
94
|
none: false
|
132
|
-
requirements:
|
133
|
-
- -
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
hash: 11
|
136
|
-
segments:
|
137
|
-
- 3
|
138
|
-
- 0
|
139
|
-
- 6
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
140
98
|
version: 3.0.6
|
141
99
|
type: :development
|
142
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70120458745880
|
143
102
|
description: A full-stack Facebook Graph API wrapper in Ruby.
|
144
103
|
email: nov@matake.jp
|
145
104
|
executables: []
|
146
|
-
|
147
105
|
extensions: []
|
148
|
-
|
149
|
-
extra_rdoc_files:
|
106
|
+
extra_rdoc_files:
|
150
107
|
- LICENSE
|
151
108
|
- README.rdoc
|
152
|
-
files:
|
109
|
+
files:
|
153
110
|
- .document
|
154
111
|
- .gitignore
|
155
112
|
- .rspec
|
@@ -665,38 +622,30 @@ files:
|
|
665
622
|
- spec/spec_helper.rb
|
666
623
|
homepage: http://github.com/nov/fb_graph
|
667
624
|
licenses: []
|
668
|
-
|
669
625
|
post_install_message:
|
670
|
-
rdoc_options:
|
626
|
+
rdoc_options:
|
671
627
|
- --charset=UTF-8
|
672
|
-
require_paths:
|
628
|
+
require_paths:
|
673
629
|
- lib
|
674
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
630
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
675
631
|
none: false
|
676
|
-
requirements:
|
677
|
-
- -
|
678
|
-
- !ruby/object:Gem::Version
|
679
|
-
|
680
|
-
|
681
|
-
- 0
|
682
|
-
version: "0"
|
683
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
632
|
+
requirements:
|
633
|
+
- - ! '>='
|
634
|
+
- !ruby/object:Gem::Version
|
635
|
+
version: '0'
|
636
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
684
637
|
none: false
|
685
|
-
requirements:
|
686
|
-
- -
|
687
|
-
- !ruby/object:Gem::Version
|
688
|
-
|
689
|
-
segments:
|
690
|
-
- 0
|
691
|
-
version: "0"
|
638
|
+
requirements:
|
639
|
+
- - ! '>='
|
640
|
+
- !ruby/object:Gem::Version
|
641
|
+
version: '0'
|
692
642
|
requirements: []
|
693
|
-
|
694
643
|
rubyforge_project:
|
695
|
-
rubygems_version: 1.8.
|
644
|
+
rubygems_version: 1.8.17
|
696
645
|
signing_key:
|
697
646
|
specification_version: 3
|
698
647
|
summary: A full-stack Facebook Graph API wrapper in Ruby.
|
699
|
-
test_files:
|
648
|
+
test_files:
|
700
649
|
- spec/fb_graph/achievement_spec.rb
|
701
650
|
- spec/fb_graph/ad_account_spec.rb
|
702
651
|
- spec/fb_graph/ad_campaign_spec.rb
|