oauth-plugin 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,9 @@
1
+ 10/05/2009
2
+ 0.3.13
3
+ - Got rid of yahoo token. To support it correctly requires way too much work. Let them suffer the consequences of their decissions.
4
+ - GoogleToken now uses portablecontacts gem
1
5
  9/30/2009
6
+ 0.3.12
2
7
  - Added a simple PortableContacts adapter for GoogleToken
3
8
  - Added a SimpleClient wrapper to provide really simple wrapper for OAuth based json web services
4
9
  - Increased token size in consumer_tokens table because of Yahoo's oversized tokens
data/Rakefile CHANGED
@@ -28,11 +28,16 @@ begin
28
28
  gemspec.summary = "Ruby on Rails Plugin for OAuth Provider and Consumer"
29
29
  gemspec.description = "Rails plugin for implementing an OAuth Provider or Consumer"
30
30
  gemspec.email = "oauth-ruby@googlegroups.com"
31
- gemspec.homepage = "http://github.com/pelle/oauth-plugin/tree/master"
31
+ gemspec.homepage = "http://github.com/pelle/oauth-plugin"
32
32
  gemspec.authors = ["Pelle Braendgaard"]
33
33
  gemspec.add_dependency('oauth', '>= 0.3.5')
34
34
  gemspec.rubyforge_project = 'oauth'
35
35
  end
36
+
37
+ Jeweler::RubyforgeTasks.new do |rubyforge|
38
+ rubyforge.doc_task = "rdoc"
39
+ end
40
+
36
41
  rescue LoadError
37
42
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
38
43
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.12
1
+ 0.3.13
@@ -13,10 +13,6 @@
13
13
  # :secret=>"",
14
14
  # :scope=>"" # see http://code.google.com/apis/gdata/faq.html#AuthScopes
15
15
  # },
16
- # :yahoo=>{
17
- # :key=>"",
18
- # :secret=>"",
19
- # },
20
16
  # :agree2=>{
21
17
  # :key=>"",
22
18
  # :secret=>""
@@ -1,3 +1,5 @@
1
+ require 'portablecontacts'
2
+
1
3
  class GoogleToken < ConsumerToken
2
4
  GOOGLE_SETTINGS={
3
5
  :site=>"https://www.google.com",
@@ -13,29 +15,13 @@ class GoogleToken < ConsumerToken
13
15
  def self.create_consumer(options={})
14
16
  OAuth::Consumer.new credentials[:key],credentials[:secret],GOOGLE_SETTINGS.merge(options)
15
17
  end
16
-
17
- def self.portable_contacts_consumer
18
- @portable_contacts_consumer||= create_consumer :site=>"http://www-opensocial.googleusercontent.com"
19
- end
20
-
21
-
18
+
22
19
  def self.get_request_token(callback_url, scope=nil)
23
20
  consumer.get_request_token({:oauth_callback=>callback_url}, :scope=>scope||credentials[:scope]||"http://www-opensocial.googleusercontent.com/api/people")
24
21
  end
25
22
 
26
23
  def portable_contacts
27
- @portable_contacts||= GooglePortableContacts.new(OAuth::AccessToken.new( self.class.portable_contacts_consumer, token, secret))
24
+ @portable_contacts||= PortableContacts::Client.new "http://www-opensocial.googleusercontent.com/api/people", client
28
25
  end
29
-
30
- class GooglePortableContacts < Oauth::Models::Consumers::SimpleClient
31
26
 
32
- def me
33
- get("/api/people/@me/@self")
34
- end
35
-
36
- def all
37
- get("/api/people/@me/@all")
38
- end
39
-
40
- end
41
27
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{oauth-plugin}
8
- s.version = "0.3.12"
8
+ s.version = "0.3.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pelle Braendgaard"]
12
- s.date = %q{2009-09-30}
12
+ s.date = %q{2009-10-05}
13
13
  s.description = %q{Rails plugin for implementing an OAuth Provider or Consumer}
14
14
  s.email = %q{oauth-ruby@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -85,7 +85,6 @@ Gem::Specification.new do |s|
85
85
  "lib/oauth/models/consumers/services/fireeagle_token.rb",
86
86
  "lib/oauth/models/consumers/services/google_token.rb",
87
87
  "lib/oauth/models/consumers/services/twitter_token.rb",
88
- "lib/oauth/models/consumers/services/yahoo_token.rb",
89
88
  "lib/oauth/models/consumers/simple_client.rb",
90
89
  "lib/oauth/models/consumers/token.rb",
91
90
  "oauth-plugin.gemspec",
@@ -93,7 +92,7 @@ Gem::Specification.new do |s|
93
92
  "tasks/oauth_tasks.rake",
94
93
  "uninstall.rb"
95
94
  ]
96
- s.homepage = %q{http://github.com/pelle/oauth-plugin/tree/master}
95
+ s.homepage = %q{http://github.com/pelle/oauth-plugin}
97
96
  s.rdoc_options = ["--charset=UTF-8"]
98
97
  s.require_paths = ["lib"]
99
98
  s.rubyforge_project = %q{oauth}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pelle Braendgaard
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-30 00:00:00 -04:00
12
+ date: 2009-10-05 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -100,7 +100,6 @@ files:
100
100
  - lib/oauth/models/consumers/services/fireeagle_token.rb
101
101
  - lib/oauth/models/consumers/services/google_token.rb
102
102
  - lib/oauth/models/consumers/services/twitter_token.rb
103
- - lib/oauth/models/consumers/services/yahoo_token.rb
104
103
  - lib/oauth/models/consumers/simple_client.rb
105
104
  - lib/oauth/models/consumers/token.rb
106
105
  - oauth-plugin.gemspec
@@ -108,7 +107,7 @@ files:
108
107
  - tasks/oauth_tasks.rake
109
108
  - uninstall.rb
110
109
  has_rdoc: true
111
- homepage: http://github.com/pelle/oauth-plugin/tree/master
110
+ homepage: http://github.com/pelle/oauth-plugin
112
111
  licenses: []
113
112
 
114
113
  post_install_message:
@@ -1,109 +0,0 @@
1
- class YahooToken < ConsumerToken
2
- YAHOO_SETTINGS={
3
- :site=>"https://www.yahoo.com",
4
- :request_token_url => "https://api.login.yahoo.com/oauth/v2/get_request_token",
5
- :authorize_url => "https://api.login.yahoo.com/oauth/v2/request_auth",
6
- :access_token_url => "https://api.login.yahoo.com/oauth/v2/get_token"
7
- }
8
-
9
- def self.consumer
10
- @consumer||=create_consumer
11
- end
12
-
13
- def self.create_consumer(options={})
14
- OAuth::Consumer.new credentials[:key],credentials[:secret],YAHOO_SETTINGS.merge(options)
15
- end
16
-
17
- def self.social_apis_consumer
18
- @social_api_consumer||=create_consumer :site=>"http://social.yahooapis.com/v1"
19
- end
20
-
21
- def self.get_request_token(callback_url, scope=nil)
22
- YahooRequestToken.new consumer.get_request_token({:oauth_callback=>callback_url}, :scope=>scope||credentials[:scope])
23
- end
24
-
25
- # We need to do some special handling to handle this strange parameter:
26
- #
27
- class YahooRequestToken < OAuth::RequestToken
28
- def initialize(real_token)
29
- super real_token.consumer,real_token.token,real_token.secret
30
- @params=real_token.params
31
- end
32
-
33
- # handle xoauth_request_auth_url
34
- def authorize_url(params = nil)
35
- if @params[:xoauth_request_auth_url]
36
- return @params[:xoauth_request_auth_url]
37
- else
38
- super params
39
- end
40
- end
41
- end
42
-
43
- def social_api
44
- @social_api ||= SocialAPI.new(OAuth::AccessToken.new( self.class.social_apis_consumer, token, secret))
45
- end
46
-
47
- class SocialAPI < Oauth::Models::Consumers::SimpleClient
48
- # initial implementation of this
49
- # http://developer.yahoo.com/social/rest_api_guide/index.html
50
- # Please fork and submit improvements here
51
- def guid
52
- @guid||=get("/v1/me/guid")["guid"]["value"]
53
- end
54
-
55
- def usercard
56
- get("/v1/user/#{guid}/profile/usercard")
57
- end
58
-
59
- def idcard
60
- get("/v1/user/#{guid}/profile/idcard")
61
- end
62
-
63
- def tinyusercard
64
- get("/v1/user/#{guid}/profile/tinyusercard")
65
- end
66
-
67
- def profile
68
- get("/v1/user/#{guid}/profile")
69
- end
70
-
71
- def contacts
72
- get("/v1/user/#{guid}/contacts")
73
- end
74
-
75
- end
76
- end
77
-
78
-
79
- # I have reported this as a bug to Yahoo, but on certain occassions their tokens are returned with spaces that confuse CGI.parse.
80
- # The only change below is that it strips the response.body. Once Yahoo fixes this I will remove this whole section.
81
- module OAuth
82
- class Consumer
83
-
84
- def token_request(http_method, path, token = nil, request_options = {}, *arguments)
85
- response = request(http_method, path, token, request_options, *arguments)
86
-
87
- case response.code.to_i
88
-
89
- when (200..299)
90
- # symbolize keys
91
- # TODO this could be considered unexpected behavior; symbols or not?
92
- # TODO this also drops subsequent values from multi-valued keys
93
-
94
- CGI.parse(response.body.strip).inject({}) do |h,(k,v)|
95
- h[k.to_sym] = v.first
96
- h[k] = v.first
97
- h
98
- end
99
- when (300..399)
100
- # this is a redirect
101
- response.error!
102
- when (400..499)
103
- raise OAuth::Unauthorized, response
104
- else
105
- response.error!
106
- end
107
- end
108
- end
109
- end