koala 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.7.4
2
+ -- Fixed bug with get_user_from_cookies
3
+
1
4
  v0.7.3
2
5
  -- Added support for picture sizes -- thanks thhermansen for the patch!
3
6
  -- Adjusted the return values for several methods (get_access_token, get_app_access_token, get_token_from_session_key, get_tokens_from_session_keys, get_user_from_cookies)
@@ -8,7 +11,7 @@ v0.7.3
8
11
  -- There are new info methods (get_access_token_info, get_app_access_token_info, get_token_info_from_session_keys, and get_user_info_from_cookies) that natively return hashes, for when you want the expiration date
9
12
  -- Responses with HTTP status 500+ now properly throw errors under Net::HTTP
10
13
  -- Updated changelog
11
- -- Added license and copyright
14
+ -- Added license
12
15
 
13
16
  v0.7.2
14
17
  -- Added support for exchanging session keys for OAuth access tokens (get_token_from_session_key for single keys, get_tokens_from_session_keys for multiple)
data/Manifest CHANGED
@@ -2,21 +2,8 @@ CHANGELOG
2
2
  LICENSE
3
3
  Manifest
4
4
  Rakefile
5
- examples/oauth_playground/Capfile
6
- examples/oauth_playground/LICENSE
7
- examples/oauth_playground/Rakefile
8
- examples/oauth_playground/config.ru
9
- examples/oauth_playground/config/deploy.rb
10
- examples/oauth_playground/config/facebook.yml
11
- examples/oauth_playground/lib/load_facebook.rb
12
- examples/oauth_playground/lib/oauth_playground.rb
13
- examples/oauth_playground/readme.md
14
- examples/oauth_playground/spec/oauth_playground_spec.rb
15
- examples/oauth_playground/spec/spec_helper.rb
16
- examples/oauth_playground/tmp/restart.txt
17
- examples/oauth_playground/views/index.erb
18
- examples/oauth_playground/views/layout.erb
19
5
  init.rb
6
+ koala.gemspec
20
7
  lib/koala.rb
21
8
  lib/koala/graph_api.rb
22
9
  lib/koala/http_services.rb
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  require 'echoe'
5
5
 
6
6
  # gem management
7
- Echoe.new('koala', '0.7.3') do |p|
7
+ Echoe.new('koala', '0.7.4') do |p|
8
8
  p.summary = "A lightweight, flexible library for Facebook with support for the Graph API, the old REST API, realtime updates, and OAuth validation."
9
9
  p.description = "Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write access to the social graph via the Graph API and the older REST API, as well as support for realtime updates and OAuth and Facebook Connect authentication. Koala is fully tested and supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services."
10
10
  p.url = "http://github.com/arsduo/koala"
data/koala.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{koala}
5
- s.version = "0.7.3"
5
+ s.version = "0.7.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional"]
9
- s.date = %q{2010-06-22}
9
+ s.date = %q{2010-06-23}
10
10
  s.description = %q{Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write access to the social graph via the Graph API and the older REST API, as well as support for realtime updates and OAuth and Facebook Connect authentication. Koala is fully tested and supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services.}
11
11
  s.email = %q{alex@alexkoppel.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "lib/koala.rb", "lib/koala/graph_api.rb", "lib/koala/http_services.rb", "lib/koala/realtime_updates.rb", "lib/koala/rest_api.rb"]
13
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "Rakefile", "examples/oauth_playground/Capfile", "examples/oauth_playground/LICENSE", "examples/oauth_playground/Rakefile", "examples/oauth_playground/config.ru", "examples/oauth_playground/config/deploy.rb", "examples/oauth_playground/config/facebook.yml", "examples/oauth_playground/lib/load_facebook.rb", "examples/oauth_playground/lib/oauth_playground.rb", "examples/oauth_playground/readme.md", "examples/oauth_playground/spec/oauth_playground_spec.rb", "examples/oauth_playground/spec/spec_helper.rb", "examples/oauth_playground/tmp/restart.txt", "examples/oauth_playground/views/index.erb", "examples/oauth_playground/views/layout.erb", "init.rb", "lib/koala.rb", "lib/koala/graph_api.rb", "lib/koala/http_services.rb", "lib/koala/realtime_updates.rb", "lib/koala/rest_api.rb", "readme.md", "spec/facebook_data.yml", "spec/koala/api_base_tests.rb", "spec/koala/graph_and_rest_api/graph_and_rest_api_no_token_tests.rb", "spec/koala/graph_and_rest_api/graph_and_rest_api_with_token_tests.rb", "spec/koala/graph_api/graph_api_no_access_token_tests.rb", "spec/koala/graph_api/graph_api_with_access_token_tests.rb", "spec/koala/live_testing_data_helper.rb", "spec/koala/net_http_service_tests.rb", "spec/koala/oauth/oauth_tests.rb", "spec/koala/realtime_updates/realtime_updates_tests.rb", "spec/koala/rest_api/rest_api_no_access_token_tests.rb", "spec/koala/rest_api/rest_api_with_access_token_tests.rb", "spec/koala_spec.rb", "spec/koala_spec_helper.rb", "spec/koala_spec_without_mocks.rb", "spec/mock_facebook_responses.yml", "spec/mock_http_service.rb", "koala.gemspec"]
13
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "Rakefile", "init.rb", "koala.gemspec", "lib/koala.rb", "lib/koala/graph_api.rb", "lib/koala/http_services.rb", "lib/koala/realtime_updates.rb", "lib/koala/rest_api.rb", "readme.md", "spec/facebook_data.yml", "spec/koala/api_base_tests.rb", "spec/koala/graph_and_rest_api/graph_and_rest_api_no_token_tests.rb", "spec/koala/graph_and_rest_api/graph_and_rest_api_with_token_tests.rb", "spec/koala/graph_api/graph_api_no_access_token_tests.rb", "spec/koala/graph_api/graph_api_with_access_token_tests.rb", "spec/koala/live_testing_data_helper.rb", "spec/koala/net_http_service_tests.rb", "spec/koala/oauth/oauth_tests.rb", "spec/koala/realtime_updates/realtime_updates_tests.rb", "spec/koala/rest_api/rest_api_no_access_token_tests.rb", "spec/koala/rest_api/rest_api_with_access_token_tests.rb", "spec/koala_spec.rb", "spec/koala_spec_helper.rb", "spec/koala_spec_without_mocks.rb", "spec/mock_facebook_responses.yml", "spec/mock_http_service.rb"]
14
14
  s.homepage = %q{http://github.com/arsduo/koala}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Koala", "--main", "readme.md"]
16
16
  s.require_paths = ["lib"]
data/lib/koala.rb CHANGED
@@ -139,12 +139,10 @@ module Koala
139
139
  alias_method :get_user_info_from_cookies, :get_user_info_from_cookie
140
140
 
141
141
  def get_user_from_cookie(cookies)
142
- # overload this to be backward compatible with older implementations
143
- # icky ruby magic, but it's _really_ cool we can do this
144
- info = get_user_info_from_cookies(cookies)
145
- string = info["uid"]
146
-
147
- overload_as_hash(string, info)
142
+ if info = get_user_info_from_cookies(cookies)
143
+ string = info["uid"]
144
+ overload_as_hash(string, info)
145
+ end
148
146
  end
149
147
  alias_method :get_user_from_cookies, :get_user_from_cookie
150
148
 
@@ -97,11 +97,18 @@ class FacebookOAuthTests < Test::Unit::TestCase
97
97
  @oauth.get_user_from_cookies(data)
98
98
  end
99
99
 
100
- it "should use return a string" do
100
+ it "should use return a string if the cookies are valid" do
101
101
  result = @oauth.get_user_from_cookies(@oauth_data["valid_cookies"])
102
102
  result.should be_a(String)
103
103
  end
104
104
 
105
+ it "should return nil if the cookies are invalid" do
106
+ # make an invalid string by replacing some values
107
+ bad_cookie_hash = @oauth_data["valid_cookies"].inject({}) { |hash, value| hash[value[0]] = value[1].gsub(/[0-9]/, "3") }
108
+ result = @oauth.get_user_from_cookies(bad_cookie_hash)
109
+ result.should be_nil
110
+ end
111
+
105
112
  describe "backward compatibility" do
106
113
  before :each do
107
114
  @result = @oauth.get_user_from_cookies(@oauth_data["valid_cookies"])
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 3
9
- version: 0.7.3
8
+ - 4
9
+ version: 0.7.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-22 00:00:00 -07:00
17
+ date: 2010-06-23 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -37,21 +37,8 @@ files:
37
37
  - LICENSE
38
38
  - Manifest
39
39
  - Rakefile
40
- - examples/oauth_playground/Capfile
41
- - examples/oauth_playground/LICENSE
42
- - examples/oauth_playground/Rakefile
43
- - examples/oauth_playground/config.ru
44
- - examples/oauth_playground/config/deploy.rb
45
- - examples/oauth_playground/config/facebook.yml
46
- - examples/oauth_playground/lib/load_facebook.rb
47
- - examples/oauth_playground/lib/oauth_playground.rb
48
- - examples/oauth_playground/readme.md
49
- - examples/oauth_playground/spec/oauth_playground_spec.rb
50
- - examples/oauth_playground/spec/spec_helper.rb
51
- - examples/oauth_playground/tmp/restart.txt
52
- - examples/oauth_playground/views/index.erb
53
- - examples/oauth_playground/views/layout.erb
54
40
  - init.rb
41
+ - koala.gemspec
55
42
  - lib/koala.rb
56
43
  - lib/koala/graph_api.rb
57
44
  - lib/koala/http_services.rb
@@ -75,7 +62,6 @@ files:
75
62
  - spec/koala_spec_without_mocks.rb
76
63
  - spec/mock_facebook_responses.yml
77
64
  - spec/mock_http_service.rb
78
- - koala.gemspec
79
65
  has_rdoc: true
80
66
  homepage: http://github.com/arsduo/koala
81
67
  licenses: []
@@ -1,2 +0,0 @@
1
- load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2
- load 'config/deploy' # remove this line to skip loading any of the default tasks
@@ -1,22 +0,0 @@
1
- Copyright (c) 2010 Alex Koppel
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +0,0 @@
1
- namespace :oauth_playground do
2
-
3
-
4
- end
@@ -1,27 +0,0 @@
1
- # gems
2
- require 'sinatra'
3
- require 'logger'
4
- require 'yaml'
5
-
6
- # app files
7
- require 'koala'
8
- require File.join(File.dirname(__FILE__), 'lib', 'load_facebook.rb')
9
- require File.join(File.dirname(__FILE__), 'lib', 'oauth_playground.rb')
10
-
11
- # LOGGING
12
- # set up the logfile
13
- Dir.mkdir('log') unless File.exists?('log')
14
- log_filename = File.join(File.dirname(__FILE__), "log", "sinatra.log")
15
- log = File.new(log_filename, "a+")
16
-
17
- # log requests
18
- use Rack::CommonLogger, log
19
- # log application-generated code
20
- LOGGER = Logger.new(log_filename)
21
- # log output to stdout and stderr as well
22
- $stdout.reopen(log)
23
- $stderr.reopen(log)
24
-
25
- # activate the app
26
- disable :run
27
- run OAuthPlayground
@@ -1,39 +0,0 @@
1
- set :application, "oauth_playground"
2
- set :repository, "git://github.com/arsduo/oauth_playground.git"
3
- set :domain, "oauth.twoalex.com"
4
- set :deploy_to, "$HOME/rails_apps/#{application}/"
5
-
6
- # authentication
7
- set :scm, "git"
8
- set :user, "alexkm"
9
- set :use_sudo, false
10
- ssh_options[:forward_agent] = true
11
-
12
- # web server
13
- role :web, "oauth.twoalex.com" # Your HTTP server, Apache/etc
14
- role :app, "oauth.twoalex.com" # This may be the same as your `Web` server
15
- role :db, "oauth.twoalex.com", :primary => true # This is where Rails migrations will run
16
-
17
-
18
- # other git-related commands
19
- set :branch, "master"
20
- default_run_options[:pty] = true
21
- # cache the repository locally to speed updates
22
- set :repository_cache, "git_cache"
23
- set :deploy_via, :remote_cache
24
-
25
-
26
- # passenger-specific deploy tasks
27
- namespace :deploy do
28
- task :start do
29
- run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
30
- end
31
-
32
- task :stop do
33
- # nothing
34
- end
35
-
36
- task :restart, :roles => :app, :except => { :no_release => true } do
37
- run "touch #{File.join(current_path,'tmp','restart.txt')}"
38
- end
39
- end
@@ -1,13 +0,0 @@
1
- development:
2
- api_key: 171e3563d4fee42e0ba27450838bba32
3
- secret_key: c81302ccef57cbdd2e68b2229e54cd2f
4
- app_id: 119347844754245
5
-
6
- test:
7
- api_key:
8
- secret_key:
9
-
10
- production:
11
- api_key: 25e1cec0df2b3bfa781da3ed78da3a1e
12
- secret_key: e45e55a333eec232d4206d2703de1307
13
- app_id: 119908831367602
@@ -1,3 +0,0 @@
1
- # load Facebook info for this environment
2
- FACEBOOK_INFO = YAML.load_file(File.join(File.dirname(__FILE__), "..", "config", "facebook.yml"))[ENV["RACK_ENV"]]
3
-
@@ -1,187 +0,0 @@
1
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
-
3
- require 'rubygems'
4
- require 'sinatra'
5
- require 'erb'
6
-
7
- class OAuthPlayground < Sinatra::Application
8
-
9
- set :root, APP_ROOT
10
-
11
- include Koala
12
-
13
- layout :layout
14
-
15
- get "/" do
16
- @app_data = FACEBOOK_INFO.merge("callback_url" => "#{request.scheme}://#{request.host}/")
17
- @oauth = Facebook::OAuth.new(@app_data["app_id"], @app_data["secret_key"], @app_data["callback_url"])
18
-
19
- # get authentication info
20
- set_facebook_cookies
21
- set_oauth_data
22
- set_access_token
23
-
24
- unless (@permissions = params[:permissions]) && @permissions.length > 0
25
- @active_permissions = (get_active_permissions || {}).inject([]) do |active, perm|
26
- # collect our active permissions
27
- active << perm[0].to_sym if perm[1] == 1
28
- active
29
- end
30
- @fetched_permissions = true
31
- else
32
- @active_permissions = @permissions.collect {|p| p.to_sym}
33
- end
34
-
35
- @available_permissions = [
36
- {:name => "User Activity", :perms => ACTIVITY_PERMISSIONS},
37
- {:name => "User Info", :perms => USER_PERMISSIONS},
38
- {:name => "Friend Info", :perms => FRIEND_PERMISSIONS}
39
- ]
40
-
41
- erb :index
42
- end
43
-
44
- get "/subscriptions" do
45
- # validate that this is a valid response
46
- # it will automatically render the result of the verification
47
- # e.g. either the challenge phrase or false
48
- subscription = Facebook::RealtimeUpdates.meet_challenge(params) do |verification_token|
49
- token_parts = verification_token.split("|")
50
- expected = Digest::MD5.hexdigest("#{token_parts.first}~koala")
51
- logger.info "expected: #{expected}"
52
- logger.info "got: #{token_parts.last}"
53
- # determine if this is a valid token -- that is, if the send part is a properly encoding of the first
54
- expected == token_parts.last
55
- end
56
- end
57
-
58
- helpers do
59
- def logger
60
- LOGGER
61
- end
62
- end
63
-
64
- # helpers
65
-
66
- # set up our understanding of the user's session
67
-
68
- def set_access_token
69
- # get the access token from wherever we can
70
- @access_token ||= (set_oauth_data && @oauth_access_token) || (set_facebook_cookies && @cookie_access_token)
71
- end
72
-
73
- def set_oauth_data
74
- unless @oauth_access_token
75
- if (@code = params[:code]) && @raw_access_response = @oauth.send(:fetch_token_string, {:code => @code, :redirect_uri => @app_data["callback_url"]})
76
- parsed = @oauth.send(:parse_access_token, @raw_access_response)
77
- @oauth_access_token = parsed["access_token"]
78
- @expiration = parsed["expires"] || "Does not expire (offline)"
79
- end
80
- end
81
-
82
- @oauth_access_token
83
- end
84
-
85
- def set_facebook_cookies
86
- unless @facebook_cookies
87
- if @facebook_cookies = @oauth.get_user_from_cookie(request.cookies)
88
- @cookie_access_token = @facebook_cookies["access_token"]
89
- end
90
- end
91
-
92
- @facebook_cookies
93
- end
94
-
95
- def set_uid
96
- # get the OAuth data, including fetching the access token, if available and necessary
97
- # e.g. if we have an OAuth token and no cookie data
98
- unless @uid
99
- if @facebook_cookies
100
- @uid = @facebook_cookies["uid"]
101
- elsif token = set_access_token
102
- # we have to fetch the info
103
- @graph = Facebook::GraphAPI.new(token)
104
- result = @graph.get_object("me")
105
- @uid = result["id"]
106
- end
107
- end
108
- @uid
109
- end
110
-
111
- # fetch the active permissions about the user
112
- def get_active_permissions
113
- set_access_token
114
- if @access_token && !@permissions && set_uid
115
- # if we don't have permissions set but have an access token
116
- # grab the user's info
117
- @rest = Facebook::RestAPI.new(@access_token)
118
- result = @rest.fql_query("select #{all_permissions.join(",")} from permissions where uid = #{@uid.to_s}")
119
- result.first
120
- end
121
- end
122
-
123
- # list of permissions
124
-
125
- def all_permissions
126
- ACTIVITY_PERMISSIONS + USER_PERMISSIONS + FRIEND_PERMISSIONS
127
- end
128
-
129
- ACTIVITY_PERMISSIONS = [
130
- :publish_stream, # Enables your application to post content, comments, and likes to a user's stream and to the streams of the user's friends, without prompting the user each time.
131
- :create_event, # Enables your application to create and modify events on the user's behalf
132
- :rsvp_event, # Enables your application to RSVP to events on the user's behalf
133
- :sms, # Enables your application to send messages to the user and respond to messages from the user via text message
134
- :offline_access # Enables your application to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.
135
- ]
136
-
137
- USER_PERMISSIONS = [
138
- :email, # Provides access to the user's primary email address in the email property. Do not spam users. Your use of email must comply both with Facebook policies and with the CAN-SPAM Act.
139
- :read_insights, # Provides read access to the Insights data for pages, applications, and domains the user owns.
140
- :read_stream, # Provides access to all the posts in the user's News Feed and enables your application to perform searches against the user's News Feed
141
- :user_about_me, # Provides access to the "About Me" section of the profile in the about property
142
- :user_activities, # Provides access to the user's list of activities as the activities connection
143
- :user_birthday, # Provides access to the full birthday with year as the birthday_date property
144
- :user_education_history, # Provides access to education history as the education property
145
- :user_events, # Provides access to the list of events the user is attending as the events connection
146
- :user_groups, # Provides access to the list of groups the user is a member of as the groups connection
147
- :user_hometown, # Provides access to the user's hometown in the hometown property
148
- :user_interests, # Provides access to the user's list of interests as the interests connection
149
- :user_likes, # Provides access to the list of all of the pages the user has liked as the likes connection
150
- :user_location, # Provides access to the user's current location as the current_location property
151
- :user_notes, # Provides access to the user's notes as the notes connection
152
- :user_online_presence, # Provides access to the user's online/offline presence
153
- :user_photo_video_tags, # Provides access to the photos the user has been tagged in as the photos connection
154
- :user_photos, # Provides access to the photos the user has uploaded
155
- :user_relationships, # Provides access to the user's family and personal relationships and relationship status
156
- :user_religion_politics, # Provides access to the user's religious and political affiliations
157
- :user_status, # Provides access to the user's most recent status message
158
- :user_videos, # Provides access to the videos the user has uploaded
159
- :user_website, # Provides access to the user's web site URL
160
- :user_work_history # Provides access to work history as the work property
161
- ]
162
-
163
- FRIEND_PERMISSIONS = [
164
- :read_friendlists, # Provides read access to the user's friend lists
165
- :read_requests, # Provides read access to the user's friend requests
166
- :friends_about_me, # Provides access to the "About Me" section of the profile in the about property
167
- :friends_activities, # Provides access to the user's list of activities as the activities connection
168
- :friends_birthday, # Provides access to the full birthday with year as the birthday_date property
169
- :friends_education_history, # Provides access to education history as the education property
170
- :friends_events, # Provides access to the list of events the user is attending as the events connection
171
- :friends_groups, # Provides access to the list of groups the user is a member of as the groups connection
172
- :friends_hometown, # Provides access to the user's hometown in the hometown property
173
- :friends_interests, # Provides access to the user's list of interests as the interests connection
174
- :friends_likes, # Provides access to the list of all of the pages the user has liked as the likes connection
175
- :friends_location, # Provides access to the user's current location as the current_location property
176
- :friends_notes, # Provides access to the user's notes as the notes connection
177
- :friends_online_presence, # Provides access to the user's online/offline presence
178
- :friends_photo_video_tags, # Provides access to the photos the user has been tagged in as the photos connection
179
- :friends_photos, # Provides access to the photos the user has uploaded
180
- :friends_relationships, # Provides access to the user's family and personal relationships and relationship status
181
- :friends_religion_politics, # Provides access to the user's religious and political affiliations
182
- :friends_status, # Provides access to the user's most recent status message
183
- :friends_videos, # Provides access to the videos the user has uploaded
184
- :friends_website, # Provides access to the user's web site URL
185
- :friends_work_history # Provides access to work history as the work property
186
- ]
187
- end
@@ -1,8 +0,0 @@
1
- A simple OAuth Playground chock full of the info you need to test your OAuth-based Facebook application.
2
-
3
- To Do's
4
- =======
5
-
6
- * Extend the permissions controls to cover all available permissions
7
- * Make expiration dates human-readable
8
- * Let people plug in their own app (updating the app's connect properties through setAppProperties)
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
- require 'ruby-debug'
3
-
4
- describe 'OAuthPlayground' do
5
- before :each do
6
- @hydra = Typhoeus::Hydra.hydra
7
- end
8
-
9
- after :each do
10
- @hydra.clear_stubs
11
- end
12
-
13
- it 'should load the index' do
14
- get '/'
15
- last_response.should be_ok
16
- end
17
-
18
- =begin
19
- # unfortunately, this fails when you pass the get method a param named code!
20
- # fixing this will require some mucking around in Rack::Test
21
-
22
- it "should make a request to Facebook's OAuth server when passed a code" do
23
- test_string = Regexp.new("The time is #{Time.now.to_i}")
24
-
25
- # stub out the request and make sure it's returned
26
- @hydra.stub("https://#{Koala::Facebook::GRAPH_SERVER}/oauth/access_token", "get").and_return(test_string)
27
-
28
- get "/", {"code" => "foo_bar"}
29
-
30
- # make sure the body includes the request string
31
- last_response.body.should =~ test_string
32
- end
33
- =end
34
- end
35
-
@@ -1,36 +0,0 @@
1
- require 'rubygems'
2
- require 'sinatra'
3
- require 'rack/test'
4
- require 'typhoeus'
5
- require 'koala'
6
-
7
- require File.join(File.dirname(__FILE__), '..', 'lib', 'oauth_playground.rb')
8
- require File.join(File.dirname(__FILE__), '..', 'lib', 'load_facebook.rb')
9
-
10
- OAuthPlayground.set(
11
- :environment => :test,
12
- :run => false,
13
- :raise_errors => true,
14
- :logging => false
15
- )
16
-
17
- module TestHelper
18
-
19
- def app
20
- # change to your app class if using the 'classy' style
21
- OAuthPlayground
22
- end
23
-
24
- def body
25
- last_response.body
26
- end
27
-
28
- def status
29
- last_response.status
30
- end
31
-
32
- include Rack::Test::Methods
33
-
34
- end
35
-
36
- include TestHelper
File without changes
@@ -1,206 +0,0 @@
1
- <div id="header">
2
- <h1>Facebook OAuth Playground</h1>
3
- <h4>Powered by <a href="http://github.com/arsduo/koala" target="_blank">Koala</a></h2>
4
- <h4>For novelty use only. Remember, the application's secret key is public.</h4>
5
- </div>
6
-
7
- <style>
8
- #header {
9
- text-align: center;
10
- }
11
-
12
- h1, h2, h3, h4 { margin: 0; }
13
-
14
- .section {
15
- border: 1px solid black;
16
- padding: 10px;
17
- -moz-border-radius: 9px;
18
- -webkit-border-radius: 9px;
19
- margin-bottom: 10px;
20
- width: 100%;
21
- }
22
-
23
- #contents {
24
- border: 2px solid #CCC;
25
- border-width: 2px 0;
26
- background-color: #EEE;
27
- padding: 14px 3px 8px 8px;
28
- }
29
-
30
- #configurationInfo {
31
- float:left;
32
- margin-right: 2.5%;
33
- width: 25%;
34
- }
35
-
36
- #configurationInfo .section {
37
- background-color: #CCC;
38
- }
39
-
40
- #permissions .header {
41
- margin-bottom: 5px;
42
- }
43
-
44
- #permissions .list {
45
- height: 380px;
46
- overflow: auto;
47
- }
48
-
49
- #generatedInfo {
50
- float: left;
51
- width: 70%;
52
- }
53
-
54
- #generatedInfo .section {
55
- border-color: gray;
56
- background: #DDD;
57
- overflow: auto;
58
- }
59
-
60
- .clearFloat {
61
- height: 1px;
62
- height: 0px;
63
- clear: both;
64
- overflow: hidden;
65
- }
66
-
67
- ul, li { margin: 0; padding: 0; list-style: none; }
68
- ul { margin: 12px 0; }
69
-
70
- .code {
71
- font-family: Courier, fixed;
72
- font-size: 1.15em;
73
- width: 100%;
74
- }
75
-
76
- .explanation {
77
- font-size: 0.9em;
78
- }
79
-
80
- .datumName {
81
- font-weight: bold;
82
- }
83
-
84
- .permissionType {
85
- font-style: italic;
86
- }
87
- </style>
88
-
89
- </style>
90
-
91
- <div id="contents">
92
-
93
- <div id="configurationInfo">
94
- <div id="fbApp" class="section">
95
- <h3>Facebook App Info</h3>
96
- <ul>
97
- <% @app_data.each_pair do |key, value| %>
98
- <li><span class="datumName"><%= key %>:</span> <%= value %></li>
99
- <% end %>
100
- </ul>
101
- </div>
102
-
103
- <div id="permissions" class="section">
104
- <form method="get">
105
- <div class="header">
106
- <h3>Permissions</h3>
107
- <input type="submit" value="Update permissions" />
108
- <a href="/">Reset Selection</a>
109
- <div class="explanation">Choose permissions for the OAuth URL and the fb:login button.</div>
110
- <% if @fetched_permissions %>
111
- <div class="permissionType">Showing currently-active permissions</div>
112
- <div class="explanation">(These were fetched by Koala as the page loaded!)</div>
113
- <% else %>
114
- <div class="permissionType">Showing selected permissions</div>
115
- <% end %>
116
- </div>
117
-
118
- <div class="list">
119
- <% @available_permissions.each do |permissions| %>
120
- <h4><%= permissions[:name] %> Permissions</h4>
121
- <ul>
122
- <% permissions[:perms].each do |p| %>
123
- <li>
124
- <input type="checkbox" id="permission<%= p %>" name="permissions[]" value="<%= p %>" <%= @active_permissions.include?(p) ? "checked='checked'" : "" %> />
125
- <label for="permission<%= p %>"><%= p %></a> (<a href="#" onclick="FB.api({method: 'auth.revokeExtendedPermission', perm: '<%= p %>'}, function(response) { alert(response) }); return false;">revoke</a>)
126
- </li>
127
- <% end %>
128
- </ul>
129
- <% end %>
130
- </div>
131
- </form>
132
- </div>
133
- </div>
134
-
135
- <div id="generatedInfo">
136
- <div id="oauthURLs" class="section">
137
- <h3>OAuth URLs</h3>
138
- <ul>
139
- <li><span class="datumName">Generate a code:</span> <a href="<%= @oauth.url_for_oauth_code(:permissions => @permissions) %>"><%= @oauth.url_for_oauth_code(:permissions => @permissions) %></a></li>
140
- <li><span class="datumName">OAuth code:</span> <%= @code || "click on the link above" %></li>
141
- <li>
142
- <span class="datumName">Access token:</span> <%= @oauth_access_token || "click on the link above" %>
143
- <% if @oauth_access_token %><div class="explanation">This was fetched by Koala as the page loaded!</div><% end %>
144
- </li>
145
- <li><span class="datumName">Expiration:</span> <%= @expiration || "click on the link above" %></li>
146
- <li><span class="datumName">Raw access response:</span> <%= @raw_access_response || "click on the link above" %></li>
147
- <li><span class="datumName">URL for access code:</span>
148
- <% if @code %>
149
- <a href="<%= @oauth.url_for_access_token(@code) %>"><%= @oauth.url_for_access_token(@code) %></a>
150
- <% else %>
151
- click on the link above
152
- <% end %>
153
- </li>
154
- </ul>
155
- </div>
156
-
157
- <div id="jsLogin" class="section">
158
- <h3>Javascript Login (e.g. Facebook Connect)</h3>
159
- <p>
160
- <fb:login-button onlogin="location.reload()" perms="<%= (@permissions || []).join(",") %>"></fb:login-button>
161
- <% if @permissions %>
162
- and prompt for <%= @permissions.join(", ") %>
163
- <% end %>
164
- <% if @facebook_cookies %>
165
- <div class="logout">
166
- <a href="#" onclick="FB.logout(function() { location.reload() }); return false;">Logout</a>
167
- </div>
168
- <% end %>
169
- </p>
170
- </div>
171
-
172
- <div id="cookieInfo" class="section">
173
- <h3>Cookie info</h3>
174
- <ul>
175
- <% if @facebook_cookies %>
176
- <% @facebook_cookies.each_pair do |key, value| %>
177
- <li><span class="datumName"><%= key %>:</span> <%= value %></li>
178
- <% end %>
179
- <% else %>
180
- <li>You're not signed in via Javascript. Login below.</li>
181
- <% end %>
182
- <li><span class="datumName">Raw hash</span>:
183
- <div class="code"><%= request.cookies.inspect %></div>
184
- </li>
185
- </ul>
186
- </div>
187
-
188
- <div id="koala" class="section">
189
- <h3>Koala</h3>
190
- <ul>
191
- <li><span class="datumName">GraphAPI:</span>
192
- <div class="code"><%= @access_token ? "@graph = Koala::Facebook::GraphAPI.new(\"#{@access_token}\")" : "sign in above" %></div>
193
- </li>
194
- <li><span class="datumName">OAuth:</span>
195
- <div class="code">@oauth = Koala::Facebook::OAuth.new(<%= @app_data["app_id"] %>, "<%= @app_data["secret_key"] %>", "<%= @app_data["callback_url"] %>")</div>
196
- </li>
197
- </ul>
198
- </div>
199
- </div>
200
-
201
- <div class="clearFloat">&nbsp;</div>
202
- </div>
203
-
204
- <center>
205
- <h5>Check out the playground's code at <a href="http://github.com/arsduo/oauth_playground">http://github.com/arsduo/oauth_playground</a>!</h5>
206
- </center>
@@ -1,39 +0,0 @@
1
- <html>
2
- <head>
3
- <title>Facebook OAuth Playground</title>
4
- <meta name="description" content="Making it easier to play with Facebook's new Graph API and OAuth authentication."></meta>
5
- <style>
6
- body {
7
- font-family: verdana, arial, sans-serif;
8
- font-size: 12px;
9
- margin: 0px;
10
- }
11
- </style>
12
- </head>
13
- <body>
14
-
15
- <script type="text/javascript">
16
-
17
- var _gaq = _gaq || [];
18
- _gaq.push(['_setAccount', 'UA-16395421-1']);
19
- _gaq.push(['_trackPageview']);
20
-
21
- (function() {
22
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
23
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
24
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
25
- })();
26
-
27
- </script>
28
-
29
- <%= yield %>
30
-
31
- <div id="fb-root"></div>
32
- <script src="http://connect.facebook.net/en_US/all.js"></script>
33
- <script>
34
- FB.init({ appId: <%= @app_data["app_id"] %>, cookie: true, status: true, xfbml: true });
35
- </script>
36
-
37
- </body>
38
-
39
- </html>