authlogic-connect 0.0.3.6 → 0.0.3.8

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.
@@ -37,7 +37,7 @@ Rails 3: `Gemfile`
37
37
 
38
38
  ### 2b. Add the `OpenIdAuthentication.store`
39
39
 
40
- Do to "some strange problem":http://github.com/openid/ruby-openid/issues#issue/1 I have yet to really understand, Rails 2.3.5 doesn't like when `OpenIdAuthentication.store` is null, which means it uses the "in memory" store and for some reason fails.
40
+ Do to [some strange problem](http://github.com/openid/ruby-openid/issues#issue/1) I have yet to really understand, Rails 2.3.5 doesn't like when `OpenIdAuthentication.store` is null, which means it uses the "in memory" store and for some reason fails.
41
41
 
42
42
  So as a fix, add these at the end of your `config/environment.rb` files:
43
43
 
@@ -142,26 +142,37 @@ These are examples of what you can get from a User. Code is placed in controlle
142
142
 
143
143
  User model has the following public accessors and methods. This example assumes:
144
144
 
145
- # You've associated your Google, OpenID, and Twitter accounts with this app.
146
- # You're currently logged in via Google.
145
+ - You've associated your Google, OpenID, and Twitter accounts with this app.
146
+ - You're currently logged in via Google.
147
+
148
+ Inside the `show` method in a controller...
147
149
 
148
150
  def show
149
151
  @user = @current_user
152
+
150
153
  puts @user.tokens #=> [
151
154
  #<OpenidToken id: 12, user_id: 9, type: "OpenidToken", key: "http://my-openid-login.myopenid.com/", token: nil, secret: nil, active: nil, created_at: "2010-05-24 14:52:19", updated_at: "2010-05-24 14:52:19">,
152
155
  #<TwitterToken id: 13, user_id: 9, type: "TwitterToken", key: "my-twitter-id-123", token: "twitter-token", secret: "twitter-secret", active: nil, created_at: "2010-05-24 15:03:05", updated_at: "2010-05-24 15:03:05">,
153
156
  #<GoogleToken id: 14, user_id: 9, type: "GoogleToken", key: "my-email@gmail.com", token: "google-token", secret: "google-secret", active: nil, created_at: "2010-05-24 15:09:04", updated_at: "2010-05-24 15:09:04">]
157
+
154
158
  puts @user.tokens.length #=> 3
159
+
155
160
  # currently logged in with...
156
161
  puts @user.active_token #=> #<GoogleToken id: 14, user_id: 9, type: "GoogleToken", key: "my-email@gmail.com", token: "google-token", secret: "google-secret", active: nil, created_at: "2010-05-24 15:09:04", updated_at: "2010-05-24 15:09:04">
162
+
157
163
  puts @user.authenticated_with #=> ["twitter", "openid", "google"]
158
164
  puts @user.authenticated_with?(:twitter) #=> true
159
165
  puts @user.authenticated_with?(:facebook) #=> false
166
+
160
167
  puts @user.has_token?(:google) #=> true
168
+
161
169
  puts @user.get_token(:google) #=> #<GoogleToken id: 14, user_id: 9, type: "GoogleToken", key: "my-email@gmail.com", token: "google-token", secret: "google-secret", active: nil, created_at: "2010-05-24 15:09:04", updated_at: "2010-05-24 15:09:04">
170
+
162
171
  # change active_token
163
172
  @user.active_token = @user.get_token(:twitter)
164
173
  puts @user.active_token #=> #<TwitterToken id: 13, user_id: 9, type: "TwitterToken", key: "my-twitter-id-123", token: "twitter-token", secret: "twitter-secret", active: nil, created_at: "2010-05-24 15:03:05", updated_at: "2010-05-24 15:03:05">
174
+
175
+ # access oauth api
165
176
  @twitter = @user.active_token
166
177
  @twitter_profile = JSON.parse(@twitter.get("/account/verify_credentials.json").body) #=> twitter api stuff
167
178
  # ...
@@ -173,7 +184,7 @@ If they've associated their Facebook account with your site, you can access Face
173
184
 
174
185
  def show
175
186
  @user = @current_user
176
- token = @user.active_token
187
+ token = @user.active_token # assuming this is FacebookToken
177
188
  facebook = JSON.parse(token.get("/me"))
178
189
  @profile = {
179
190
  :id => facebook["id"],
@@ -192,6 +203,10 @@ If they've associated their Facebook account with your site, you can access Face
192
203
  - Twitter
193
204
  - Facebook
194
205
  - Google
206
+ - LinkedIn
207
+ - MySpace
208
+ - Vimeo
209
+ - Yahoo
195
210
 
196
211
  ### OpenID
197
212
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = "authlogic-connect"
8
8
  s.author = "Lance Pollard"
9
- s.version = "0.0.3.6"
9
+ s.version = "0.0.3.8"
10
10
  s.summary = "Authlogic Connect: Let your app use all of Oauth and OpenID"
11
11
  s.homepage = "http://github.com/viatropos/authlogic-connect"
12
12
  s.email = "lancejpollard@gmail.com"
@@ -1,10 +1,19 @@
1
1
  # http://developer.linkedin.com/docs/DOC-1008
2
+ # https://www.linkedin.com/secure/developer
2
3
  # http://github.com/pengwynn/linkedin/tree/master/lib/linked_in/
3
4
  class LinkedInToken < OauthToken
4
5
 
6
+ key do |access_token|
7
+ body = access_token.get("https://api.linkedin.com/v1/people/~:(id)").body
8
+ id = body.gsub("<id>([^><]+)</id>", "\\1") # so we don't need to also import nokogiri
9
+ id
10
+ end
11
+
5
12
  settings "https://api.linkedin.com",
6
13
  :request_token_path => "/uas/oauth/requestToken",
7
14
  :access_token_path => "/uas/oauth/accessToken",
8
- :authorize_path => "/uas/oauth/authorize"
15
+ :authorize_path => "/uas/oauth/authorize",
16
+ :http_method => "get",
17
+ :scheme => :query_string
9
18
 
10
19
  end
@@ -1,11 +1,26 @@
1
1
  # http://wiki.developer.myspace.com/index.php?title=Category:MySpaceID
2
2
  # http://developerwiki.myspace.com/index.php?title=OAuth_REST_API_Usage_-_Authentication_Process
3
3
  # http://developerwiki.myspace.com/index.php?title=How_to_Set_Up_a_New_Application_for_OpenID
4
+ # http://developer.myspace.com/Modules/Apps/Pages/ApplyDevSandbox.aspx
5
+ # after you've signed up:
6
+ # http://developer.myspace.com/modules/apps/pages/createappaccount.aspx
7
+ # "Create a MySpaceID App"
8
+ # http://developer.myspace.com/modules/apps/pages/editapp.aspx?appid=188312&mode=create
9
+ # http://developer.myspace.com/Modules/APIs/Pages/OAuthTool.aspx
10
+ # http://developer.myspace.com/Community/forums/p/3626/15947.aspx
4
11
  class MyspaceToken < OauthToken
5
12
 
13
+ # http://wiki.developer.myspace.com/index.php?title=Portable_Contacts_REST_Resources
14
+ key do |access_token|
15
+ body = JSON.parse(access_token.get("/v2/people/@me/@self?format=json").body)
16
+ id = body["entry"]["id"]
17
+ end
18
+
6
19
  settings "http://api.myspace.com",
7
20
  :request_token_path => "/request_token",
8
21
  :authorize_path => "/authorize",
9
- :access_token_path => "/access_token"
22
+ :access_token_path => "/access_token",
23
+ :http_method => "get",
24
+ :scheme => :query_string
10
25
 
11
26
  end
@@ -87,6 +87,9 @@ class OauthToken < Token
87
87
  else
88
88
  result[:key] = access.params[self.oauth_key] || access.params[self.oauth_key.to_s] # try both
89
89
  end
90
+ else
91
+ puts "Access Token: #{access.inspect}"
92
+ raise "please set an oauth key for #{service_name.to_s}"
90
93
  end
91
94
  else
92
95
  access = consumer.web_server.get_access_token(secret, :redirect_uri => redirect_uri)
@@ -103,7 +106,9 @@ class OauthToken < Token
103
106
  yield request if block_given?
104
107
  return request.authorize_url
105
108
  else
106
- return consumer.web_server.authorize_url(:redirect_uri => callback_url, :scope => self.config[:scope])
109
+ options = {:redirect_uri => callback_url}
110
+ options[:scope] = self.config[:scope] unless self.config[:scope].blank?
111
+ return consumer.web_server.authorize_url(options)
107
112
  end
108
113
  end
109
114
 
@@ -111,8 +116,10 @@ class OauthToken < Token
111
116
  OAuth::RequestToken.new(consumer, token, secret)
112
117
  end
113
118
 
119
+ # if you pass a hash as the second parameter to consumer.get_request_token,
120
+ # ruby oauth will think this is a form and all sorts of bad things happen
114
121
  def get_request_token(callback_url)
115
- consumer.get_request_token({:oauth_callback => callback_url}, config)
122
+ consumer.get_request_token(:oauth_callback => callback_url)
116
123
  end
117
124
 
118
125
  def get_access_token(oauth_verifier)
@@ -1,8 +1,18 @@
1
1
  # http://www.vimeo.com/api/docs/oauth
2
2
  # http://www.vimeo.com/api/applications/new
3
+ # http://vimeo.com/api/applications
3
4
  class VimeoToken < OauthToken
4
5
 
6
+ key do |access_token|
7
+ body = JSON.parse(access_token.get("http://vimeo.com/api/v2/#{access_token.token}/info.json"))
8
+ user_id = body.first["id"]
9
+ end
10
+
5
11
  settings "http://vimeo.com",
6
- :authorize_url => "http://vimeo.com/oauth/authorize"
12
+ :request_token_path => "/oauth/request_token",
13
+ :authorize_path => "/oauth/authorize",
14
+ :access_token_path => "/oauth/access_token",
15
+ :http_method => "get",
16
+ :scheme => :query_string
7
17
 
8
18
  end
@@ -1,12 +1,19 @@
1
1
  # https://developer.apps.yahoo.com/dashboard/createKey.html
2
+ # https://developer.apps.yahoo.com/projects
2
3
  # http://developer.yahoo.com/oauth/guide/oauth-accesstoken.html
4
+ # http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html
5
+ # http://code.google.com/apis/gadgets/docs/oauth.html
6
+ # http://developer.yahoo.com/social/rest_api_guide/web-services-guids.html
7
+ # A GUID identifies a person
8
+ # http://social.yahooapis.com/v1/me/guid
3
9
  class YahooToken < OauthToken
4
10
 
5
- version 2
11
+ # http://social.yahooapis.com/v1/me/guid
12
+ key :xoauth_yahoo_guid
6
13
 
7
14
  settings "https://api.login.yahoo.com",
8
15
  :request_token_path => '/oauth/v2/get_request_token',
9
16
  :access_token_path => '/oauth/v2/get_token',
10
17
  :authorize_path => '/oauth/v2/request_auth'
11
18
 
12
- end
19
+ end
@@ -40,6 +40,7 @@ class Token < ActiveRecord::Base
40
40
 
41
41
  def config
42
42
  @settings ||= {}
43
+ @settings.dup
43
44
  end
44
45
 
45
46
  protected
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 0
8
8
  - 3
9
- - 6
10
- version: 0.0.3.6
9
+ - 8
10
+ version: 0.0.3.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lance Pollard
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-26 00:00:00 -07:00
18
+ date: 2010-05-27 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency