mogli 0.0.38 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mogli/authenticator.rb +11 -0
- data/lib/mogli/client.rb +11 -0
- data/lib/mogli/test_user.rb +1 -1
- data/spec/client_spec.rb +24 -0
- data/spec/user_spec.rb +2 -5
- metadata +134 -117
data/lib/mogli/authenticator.rb
CHANGED
@@ -20,6 +20,17 @@ module Mogli
|
|
20
20
|
"https://graph.facebook.com/oauth/access_token?client_id=#{client_id}&redirect_uri=#{CGI.escape(callback_url) unless callback_url.nil? || callback_url.empty?}&client_secret=#{secret}&code=#{CGI.escape(code)}"
|
21
21
|
end
|
22
22
|
|
23
|
+
def extend_access_token(oauth_token)
|
24
|
+
response = Mogli::Client.get("https://graph.facebook.com/oauth/access_token",
|
25
|
+
:query=>{
|
26
|
+
:client_id=>@client_id,
|
27
|
+
:client_secret => @secret,
|
28
|
+
:grant_type => "fb_exchange_token",
|
29
|
+
:fb_exchange_token=>oauth_token})
|
30
|
+
raise_exception_if_required(response)
|
31
|
+
Hash[response.parsed_response.split("&").map {|a| a.split("=")}]
|
32
|
+
end
|
33
|
+
|
23
34
|
def get_access_token_for_session_key(session_keys)
|
24
35
|
keystr = session_keys.is_a?(Array) ?
|
25
36
|
session_keys.join(',') : session_keys
|
data/lib/mogli/client.rb
CHANGED
@@ -111,6 +111,17 @@ module Mogli
|
|
111
111
|
client
|
112
112
|
end
|
113
113
|
|
114
|
+
def extended?
|
115
|
+
(expiration.to_i - Time.now.to_i) > 24*60*60
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
def exchange_access_token(client_id, secret)
|
120
|
+
authenticator = Mogli::Authenticator.new(client_id, secret, nil)
|
121
|
+
results = authenticator.extend_access_token(@access_token)
|
122
|
+
self.class.new(results["access_token"],Time.now.to_i+results["expires"].to_i)
|
123
|
+
end
|
124
|
+
|
114
125
|
def post(path,klass,body_args)
|
115
126
|
data = self.class.post(api_path(path),:body=>default_params.merge(body_args))
|
116
127
|
map_data(data,klass)
|
data/lib/mogli/test_user.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -121,6 +121,30 @@ describe Mogli::Client do
|
|
121
121
|
|
122
122
|
end
|
123
123
|
|
124
|
+
describe "Extending" do
|
125
|
+
it "knows if it is an extended session" do
|
126
|
+
Mogli::Client.new("1234",(Time.now.to_i + 48*60*60)).should be_extended
|
127
|
+
end
|
128
|
+
it "knows if it is not an extended session" do
|
129
|
+
Mogli::Client.new("1234",(Time.now.to_i + 2*60*60)).should_not be_extended
|
130
|
+
end
|
131
|
+
|
132
|
+
it "can get an extended session" do
|
133
|
+
response = stub(:parsed_response=>"access_token=new_token&expires=#{30*60*60*24}",:code=>200)
|
134
|
+
client = Mogli::Client.new("auth_key",Time.now.to_i)
|
135
|
+
Mogli::Client.should_receive(:get).with("https://graph.facebook.com/oauth/access_token",
|
136
|
+
:query=>{
|
137
|
+
:client_id=>"12345",
|
138
|
+
:client_secret => "secret",
|
139
|
+
:grant_type => "fb_exchange_token",
|
140
|
+
:fb_exchange_token=>"auth_key"}).and_return(response)
|
141
|
+
new_client = client.exchange_access_token("12345","secret")
|
142
|
+
new_client.access_token.should == "new_token"
|
143
|
+
new_client.should be_extended
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
124
148
|
|
125
149
|
describe "Making requests" do
|
126
150
|
it "posts with the parameters in the body" do
|
data/spec/user_spec.rb
CHANGED
@@ -44,13 +44,10 @@ describe Mogli::User do
|
|
44
44
|
describe "checking extended permissions" do
|
45
45
|
before :each do
|
46
46
|
# construct a response that will avoid errors: we're just testing query
|
47
|
-
@dummy_response =
|
48
|
-
@dummy_response.stub!(:parsed_response).and_return [{}]
|
47
|
+
@dummy_response = [{}]
|
49
48
|
|
50
49
|
# this HTTParty parsed response is taken directly from an actual fql response
|
51
|
-
@valid_response =
|
52
|
-
@valid_response.stub!(:parsed_response).and_return [{"publish_stream"=>1, "create_event"=>0, "rsvp_event"=>0, "sms"=>0, "offline_access"=>1, "publish_checkins"=>0, "user_about_me"=>0, "user_activities"=>0, "user_birthday"=>0, "user_education_history"=>0, "user_events"=>0, "user_groups"=>0, "user_hometown"=>0, "user_interests"=>0, "user_likes"=>0, "user_location"=>0, "user_notes"=>0, "user_online_presence"=>0, "user_photo_video_tags"=>0, "user_photos"=>0, "user_relationships"=>0, "user_relationship_details"=>0, "user_religion_politics"=>0, "user_status"=>0, "user_videos"=>0, "user_website"=>0, "user_work_history"=>0, "email"=>1, "read_friendlists"=>0, "read_insights"=>0, "read_mailbox"=>0, "read_requests"=>0, "read_stream"=>0, "xmpp_login"=>0, "ads_management"=>0, "user_checkins"=>0, "manage_pages"=>0}]
|
53
|
-
|
50
|
+
@valid_response = [{"publish_stream"=>1, "create_event"=>0, "rsvp_event"=>0, "sms"=>0, "offline_access"=>1, "publish_checkins"=>0, "user_about_me"=>0, "user_activities"=>0, "user_birthday"=>0, "user_education_history"=>0, "user_events"=>0, "user_groups"=>0, "user_hometown"=>0, "user_interests"=>0, "user_likes"=>0, "user_location"=>0, "user_notes"=>0, "user_online_presence"=>0, "user_photo_video_tags"=>0, "user_photos"=>0, "user_relationships"=>0, "user_relationship_details"=>0, "user_religion_politics"=>0, "user_status"=>0, "user_videos"=>0, "user_website"=>0, "user_work_history"=>0, "email"=>1, "read_friendlists"=>0, "read_insights"=>0, "read_mailbox"=>0, "read_requests"=>0, "read_stream"=>0, "xmpp_login"=>0, "ads_management"=>0, "user_checkins"=>0, "manage_pages"=>0}]
|
54
51
|
@request_regexp = /^SELECT ([\w,]*) FROM permissions WHERE uid = \d*$/
|
55
52
|
end
|
56
53
|
|
metadata
CHANGED
@@ -1,129 +1,140 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mogli
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 38
|
9
|
-
version: 0.0.38
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.39
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Mike Mangino
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: hashie
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 1
|
30
|
-
- 0
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 1.1.0
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: httmultiparty
|
36
23
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: httmultiparty
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
45
37
|
version: 0.3.6
|
46
38
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: httparty
|
50
39
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.3.6
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: httparty
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
59
53
|
version: 0.4.3
|
60
54
|
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: multi_json
|
64
55
|
prerelease: false
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.4.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: multi_json
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
73
69
|
version: 1.0.3
|
74
70
|
- - <
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
- 1
|
78
|
-
- 4
|
79
|
-
version: "1.4"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.4'
|
80
73
|
type: :runtime
|
81
|
-
version_requirements: *id004
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: json
|
84
74
|
prerelease: false
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
75
|
+
version_requirements: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.0.3
|
81
|
+
- - <
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.4'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: json
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
92
|
type: :development
|
93
|
-
version_requirements: *id005
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rake
|
96
93
|
prerelease: false
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: rake
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
104
108
|
type: :development
|
105
|
-
version_requirements: *id006
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: rspec
|
108
109
|
prerelease: false
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: rspec
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
116
124
|
type: :development
|
117
|
-
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
118
132
|
description: Simple library for accessing the Facebook Open Graph API
|
119
133
|
email: mmangino@elevatedrails.com
|
120
134
|
executables: []
|
121
|
-
|
122
135
|
extensions: []
|
123
|
-
|
124
136
|
extra_rdoc_files: []
|
125
|
-
|
126
|
-
files:
|
137
|
+
files:
|
127
138
|
- lib/mogli/action.rb
|
128
139
|
- lib/mogli/activity.rb
|
129
140
|
- lib/mogli/address.rb
|
@@ -166,37 +177,43 @@ files:
|
|
166
177
|
- lib/mogli/video.rb
|
167
178
|
- lib/mogli/work.rb
|
168
179
|
- lib/mogli.rb
|
169
|
-
|
180
|
+
- spec/app_client_spec.rb
|
181
|
+
- spec/authenticator_spec.rb
|
182
|
+
- spec/client/client_event_spec.rb
|
183
|
+
- spec/client/client_user_spec.rb
|
184
|
+
- spec/client_spec.rb
|
185
|
+
- spec/fetching_array_spec.rb
|
186
|
+
- spec/model_spec.rb
|
187
|
+
- spec/page_spec.rb
|
188
|
+
- spec/profile_spec.rb
|
189
|
+
- spec/spec_helper.rb
|
190
|
+
- spec/test_user_spec.rb
|
191
|
+
- spec/user_spec.rb
|
170
192
|
homepage: http://developers.facebook.com/docs/api
|
171
193
|
licenses: []
|
172
|
-
|
173
194
|
post_install_message:
|
174
195
|
rdoc_options: []
|
175
|
-
|
176
|
-
require_paths:
|
196
|
+
require_paths:
|
177
197
|
- lib
|
178
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
|
190
|
-
- 0
|
191
|
-
version: "0"
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
none: false
|
200
|
+
requirements:
|
201
|
+
- - ! '>='
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
+
none: false
|
206
|
+
requirements:
|
207
|
+
- - ! '>='
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
192
210
|
requirements: []
|
193
|
-
|
194
211
|
rubyforge_project:
|
195
|
-
rubygems_version: 1.
|
212
|
+
rubygems_version: 1.8.24
|
196
213
|
signing_key:
|
197
214
|
specification_version: 3
|
198
215
|
summary: Open Graph Library for Ruby
|
199
|
-
test_files:
|
216
|
+
test_files:
|
200
217
|
- spec/app_client_spec.rb
|
201
218
|
- spec/authenticator_spec.rb
|
202
219
|
- spec/client/client_event_spec.rb
|