slayer-rpx_now 0.6.24
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.
- data/.gitignore +6 -0
- data/CHANGELOG +38 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +28 -0
- data/MIGRATION +9 -0
- data/Rakefile +22 -0
- data/Readme.md +165 -0
- data/VERSION +1 -0
- data/certs/ssl_cert.pem +3154 -0
- data/init.rb +2 -0
- data/lib/rpx_now/api.rb +75 -0
- data/lib/rpx_now/contacts_collection.rb +20 -0
- data/lib/rpx_now/user_integration.rb +9 -0
- data/lib/rpx_now/user_proxy.rb +19 -0
- data/lib/rpx_now.rb +201 -0
- data/rpx_now.gemspec +63 -0
- data/spec/fixtures/get_contacts_response.json +58 -0
- data/spec/integration/mapping_spec.rb +40 -0
- data/spec/rpx_now/api_spec.rb +50 -0
- data/spec/rpx_now/contacts_collection_spec.rb +32 -0
- data/spec/rpx_now/user_proxy_spec.rb +33 -0
- data/spec/rpx_now_spec.rb +414 -0
- data/spec/spec_helper.rb +16 -0
- metadata +107 -0
data/.gitignore
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
0.6.13
|
2
|
+
------
|
3
|
+
* return an indifferent hash from user_data when possible
|
4
|
+
|
5
|
+
0.6.12
|
6
|
+
-----
|
7
|
+
* url encode obstrusive popup code token-url
|
8
|
+
0.6.0
|
9
|
+
-----
|
10
|
+
* removed optional api key as parameter: RPXNow.user_data(token, api_key, options) --> RPXNow.user_data(token, options), you may use :apiKey=>... instead
|
11
|
+
|
12
|
+
0.5.9
|
13
|
+
-----
|
14
|
+
* Switched from Get to Post requests
|
15
|
+
|
16
|
+
0.5.0
|
17
|
+
----
|
18
|
+
* ApiError is raised when API KEY was invalid (before did only return nil)
|
19
|
+
* ServerError is now seperated into ApiError and ServiceUnavailableError
|
20
|
+
|
21
|
+
0.4.2
|
22
|
+
----
|
23
|
+
* default IDs are strings, not integers, since RPX supports both
|
24
|
+
* Added username field to standart parameters
|
25
|
+
|
26
|
+
0.4
|
27
|
+
----
|
28
|
+
* The RPXNow.api_version= can be set globally
|
29
|
+
* Most methods now support :api_version=>'123', so you can specify the api_version on each call
|
30
|
+
* Added support for unobtrusive code generation. This will make the gem play nicely with developers creating unobtrusive pages with frameworks such as jQuery;
|
31
|
+
* The RPXNOW JSON responses are now parsed by Florian Frank JSON gem (http://json.rubyforge.org/);
|
32
|
+
* Removed the dependency of ActiveSupport. However, if present, ActiveSupport will be used due to its convenience methods Array#to_query and Hash#to_query.
|
33
|
+
* Added support for multiple versions of the widget. By default, everything will point to version 2;
|
34
|
+
* The specs have been updated.
|
35
|
+
|
36
|
+
0.3
|
37
|
+
----
|
38
|
+
* RPXNow::ServerError will be thrown when something is invalid/goes wrong, so watch out (not for invalid tokens in user_data)...
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.5.2)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
json (1.4.6)
|
11
|
+
rake (0.8.7)
|
12
|
+
rspec (2.5.0)
|
13
|
+
rspec-core (~> 2.5.0)
|
14
|
+
rspec-expectations (~> 2.5.0)
|
15
|
+
rspec-mocks (~> 2.5.0)
|
16
|
+
rspec-core (2.5.1)
|
17
|
+
rspec-expectations (2.5.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.5.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
jeweler
|
26
|
+
json
|
27
|
+
rake
|
28
|
+
rspec (~> 2)
|
data/MIGRATION
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
task :default => :spec
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
4
|
+
t.rspec_opts = '--backtrace --color'
|
5
|
+
end
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'jeweler'
|
9
|
+
|
10
|
+
Jeweler::Tasks.new do |gem|
|
11
|
+
gem.name = 'slayer-rpx_now'
|
12
|
+
gem.summary = "Helper to simplify RPX Now user login/creation"
|
13
|
+
gem.email = "devvlad@gmail.com"
|
14
|
+
gem.homepage = "http://github.com/slayer/#{gem.name}"
|
15
|
+
gem.authors = ["Michael Grosser", "Vlad Moskovets"]
|
16
|
+
gem.add_dependency ['json_pure']
|
17
|
+
end
|
18
|
+
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
22
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
[Janrain Engage](http://www.janrain.com/products/engage) (formerly known as RPXNow):
|
2
|
+
|
3
|
+
- Login to your page through Facebook / Twitter / Myspace / Google / OpenId / MS-LiveId / AOL / ...
|
4
|
+
- Simpler then OpenId/OAuth/xxx for developers AND users
|
5
|
+
- Publish user activity to facebook/twitter/myspace/.../-stream via the same API
|
6
|
+
- Returning users are greeted by their choosen provider
|
7
|
+
- Free for up to 2500 accounts/year (above 5k it gets [expensive](http://www.janrain.com/products/engage/pricing)...)
|
8
|
+
|
9
|
+

|
10
|
+

|
11
|
+

|
12
|
+
|
13
|
+
Usage
|
14
|
+
=====
|
15
|
+
- Get an API key @ [Janrain Engage](http://www.janrain.com/products/engage)
|
16
|
+
- run [MIGRATION](http://github.com/grosser/rpx_now/raw/master/MIGRATION)
|
17
|
+
- Build login view
|
18
|
+
- Receive user-data from Janrain to create or login User
|
19
|
+
- for more advanced features have a look at the [Janrain Engage API Docs](http://documentation.janrain.com)
|
20
|
+
|
21
|
+
Install
|
22
|
+
=======
|
23
|
+
- As Rails plugin: `rails plugin install git://github.com/grosser/rpx_now.git`
|
24
|
+
- As gem: `sudo gem install rpx_now`
|
25
|
+
|
26
|
+
Examples
|
27
|
+
========
|
28
|
+
|
29
|
+
[Example application](http://github.com/grosser/rpx_now_example), go play around!
|
30
|
+
|
31
|
+
environment.rb
|
32
|
+
--------------
|
33
|
+
|
34
|
+
RPXNow.api_key = "YOU RPX API KEY"
|
35
|
+
|
36
|
+
Controller
|
37
|
+
----------
|
38
|
+
This example uses the SessionsController, if you dont have one built it and add routes(rpx_token is a post request)
|
39
|
+
|
40
|
+
skip_before_filter :verify_authenticity_token, :only => [:rpx_token] # RPX does not pass Rails form tokens...
|
41
|
+
|
42
|
+
# user_data
|
43
|
+
# found: {:name=>'John Doe', :username => 'john', :email=>'john@doe.com', :identifier=>'blug.google.com/openid/dsdfsdfs3f3'}
|
44
|
+
# not found: nil (can happen with e.g. invalid tokens)
|
45
|
+
def rpx_token
|
46
|
+
raise "hackers?" unless data = RPXNow.user_data(params[:token])
|
47
|
+
self.current_user = User.find_by_identifier(data[:identifier]) || User.create!(data)
|
48
|
+
redirect_to '/'
|
49
|
+
end
|
50
|
+
|
51
|
+
# getting additional profile fields (these fields are rarely filled)
|
52
|
+
# all possibilities: https://rpxnow.com/docs#profile_data
|
53
|
+
data = RPXNow.user_data(params[:token], :additional => [:gender, :birthday, :photo, :providerName, ...])
|
54
|
+
|
55
|
+
# normal + raw data
|
56
|
+
RPXNow.user_data(params[:token], :additional => [:raw_response])[:raw_response]['profile]['verifiedEmail']
|
57
|
+
|
58
|
+
# only raw data
|
59
|
+
email = RPXNow.user_data(params[:token], :raw_response => true)['profile']['verifiedEmail']
|
60
|
+
|
61
|
+
# with extended info like friends, accessCredentials, portable contacts. (most Providers do not supply them)
|
62
|
+
RPXNow.user_data(params[:token], :extended => true)[:extended]['friends'][...have a look at the RPX API DOCS...]
|
63
|
+
|
64
|
+
View
|
65
|
+
----
|
66
|
+
|
67
|
+
<%=RPXNow.embed_code('My-Rpx-Domain', url_for(:controller => :session, :action => :rpx_token, :only_path => false))%>
|
68
|
+
OR
|
69
|
+
<%=RPXNow.popup_code('Login here...', 'My-Rpx-Domain', url_for(:controller => :session, :action => :rpx_token, :only_path => false), options)%>
|
70
|
+
|
71
|
+
###Options
|
72
|
+
`:language => 'en'` janrain tries to detect the users language, but you may overwrite it [possible languages](http://documentation.janrain.com/engage/widgets/localization)<br/>
|
73
|
+
`:default_provider => 'google'` [possible default providers](http://documentation.janrain.com/engage/widgets/sign-in#TOC-Default-Provider)<br/>
|
74
|
+
`:flags => 'show_provider_list'` [possible flags](http://documentation.janrain.com/engage/widgets/sign-in)<br/>
|
75
|
+
`:html => {:id => 'xxx'}` is added to the popup link (popup_code only)
|
76
|
+
|
77
|
+
###Unobtrusive / JS-last
|
78
|
+
`popup_code` can also be called with `:unobtrusive => true` ( --> just link without javascript include).
|
79
|
+
To still get the normal popup add `RPXNow.popup_source('My-Rpx-Domain', url_for(:controller => :session, :action => :rpx_token, :only_path => false), [options])`<br/>
|
80
|
+
Options like :language / :flags should be given for both.
|
81
|
+
|
82
|
+
Advanced
|
83
|
+
--------
|
84
|
+
### Versions
|
85
|
+
RPXNow.api_version = 2
|
86
|
+
|
87
|
+
### Custom domain (Plus/Pro)
|
88
|
+
RPXNow.domain = 'other-domain.com'
|
89
|
+
|
90
|
+
### Mappings (Plus/Pro)
|
91
|
+
You can map your primary keys (e.g. user.id) to identifiers, so that<br/>
|
92
|
+
users can login to the same account with multiple identifiers.
|
93
|
+
|
94
|
+
RPXNow.map(identifier, primary_key) #add a mapping
|
95
|
+
RPXNow.unmap(identifier, primary_key) #remove a mapping
|
96
|
+
RPXNow.mappings(primary_key) # [identifier1,identifier2,...]
|
97
|
+
RPXNow.all_mappings # [["1",['google.com/dsdas','yahoo.com/asdas']], ["2",[...]], ... ]
|
98
|
+
|
99
|
+
After a primary key is mapped to an identifier, when a user logs in with this identifier,
|
100
|
+
`RPXNow.user_data` will contain his `primaryKey` as `:id`.
|
101
|
+
A identifyer can only belong to one user (in doubt the last one it was mapped to)
|
102
|
+
|
103
|
+
### User integration (e.g. ActiveRecord)
|
104
|
+
class User < ActiveRecord::Base
|
105
|
+
include RPXNow::UserIntegration
|
106
|
+
end
|
107
|
+
|
108
|
+
user.rpx.identifiers == RPXNow.mappings(user.id)
|
109
|
+
user.rpx.map(identifier) == RPXNow.map(identifier, user.id)
|
110
|
+
user.rpx.unmap(identifier) == RPXNow.unmap(identifier, user.id)
|
111
|
+
|
112
|
+
### Contacts (Pro)
|
113
|
+
Retrieve all contacts for a given user:
|
114
|
+
RPXNow.contacts(identifier).each {|c| puts "#{c['displayName']}: #{c['emails']}}
|
115
|
+
|
116
|
+
### Status updates (Pro)
|
117
|
+
Send a status update to provider (a tweet/facebook-status/...) :
|
118
|
+
RPXNow.set_status(identifier, "I just registered at yourdomain.com ...")
|
119
|
+
|
120
|
+
### Activity (Pro)
|
121
|
+
Post a users activity, on their e.g. Facebook profile, complete with images, titels, rating, additional media, customized links and so on ...
|
122
|
+
|
123
|
+
RPXNow.activity( identifier,
|
124
|
+
:url => href, :action => 'Im loving my new', :user_generated_content => 'Im loving my new ... ',
|
125
|
+
:title => product.title, :description => product.description,
|
126
|
+
:action_links => [{:text => 'view >>', :href => product_url(product, :only_path => false)}],
|
127
|
+
:media => [{:type => :image, :src => product.image_url, :href => product_url(product, :only_path => false)}]
|
128
|
+
)
|
129
|
+
|
130
|
+
### Offline user data access (Plus/Pro)
|
131
|
+
Same response as auth_info but can be called with a identifier at any time.<br/>
|
132
|
+
Offline Profile Access must be enabled.
|
133
|
+
|
134
|
+
RPXNow.get_user_data(identifier, :extended => true)
|
135
|
+
|
136
|
+
### Auth info
|
137
|
+
Same response as user_data with :raw_response, but without any kind of failure detection or post processing.
|
138
|
+
RPXNow.auth_info(params[:token])
|
139
|
+
|
140
|
+
Author
|
141
|
+
======
|
142
|
+
|
143
|
+
__[rpx_now_gem mailing list](http://groups.google.com/group/rpx_now_gem)__
|
144
|
+
|
145
|
+
|
146
|
+
### [Contributors](http://github.com/grosser/rpx_now/contributors)
|
147
|
+
- [Amunds](http://github.com/Amunds)
|
148
|
+
- [Bob Groeneveld](http://metathoughtfacility.blogspot.com)
|
149
|
+
- [DBA](http://github.com/DBA)
|
150
|
+
- [dbalatero](http://github.com/dbalatero)
|
151
|
+
- [Paul Gallagher](http://tardate.blogspot.com/)
|
152
|
+
- [jackdempsey](http://jackndempsey.blogspot.com)
|
153
|
+
- [Patrick Reagan (reagent)](http://sneaq.net)
|
154
|
+
- [Joris Trooster (trooster)](http://www.interstroom.nl)
|
155
|
+
- [Mick Staugaard (staugaard)](http://mick.staugaard.com/)
|
156
|
+
- [Kasper Weibel](http://github.com/weibel)
|
157
|
+
- [Nicolas Alpi](http://www.notgeeklycorrect.com)
|
158
|
+
- [Ladislav Martincik](http://martincik.com)
|
159
|
+
- [Ben Aldred](http://github.com/benaldred)
|
160
|
+
- [Casper Fabricius](http://casperfabricius.com)
|
161
|
+
- [Avi Flombaum](http://www.aviflombaum.com)
|
162
|
+
|
163
|
+
[Michael Grosser](http://grosser.it)<br/>
|
164
|
+
michael@grosser.it<br/>
|
165
|
+
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.6.24
|