• OpenID is complex, limited and hard to use for users
  • Facebook / Twitter / Myspace / Google / MS-LiveId / AOL connections require different libraries and knowledge
  • Multiple heterogenouse providers are hard to map to a single user


  • Use RPX for universal and usable user login
  • Use view/controller helpers for easy integration

Single Interface for all providers Visitors choose from providers they already have


  • Get an API key @ RPX
  • Build login view
  • Communicate with RPX API in controller to create or login User
  • for more advanced features have a look at the RPX API Docs


  • As Rails plugin: script/plugin install git://
  • As gem: sudo gem install rpx_now


Example application, go play around!


#'mywebsite' is your subdomain/realm on RPX
<%=RPXNow.embed_code('mywebsite', url_for(:controller=>:session, :action=>:rpx_token, :only_path => false))%>
<%=RPXNow.popup_code('Login here...', 'mywebsite', url_for(:controller=>:session, :action=>:rpx_token, :only_path => false), options)%>


:language=>'en' rpx tries to detect the users language, but you may overwrite it possible languages
:default_provider=>'google' possible default providers
:flags=>'show_provider_list' possible flags

Unobtrusive / JS-last

popup_code can also be called with :unobtrusive=>true ( --> just link without javascript include).
To still get the normal popup add RPXNow.popup_source('mywebsite', url_for(:controller=>:session, :action=>:rpx_token, :only_path => false), [options]).
Options like :language / :flags should be given for both.

environment.rb do |config|
  config.gem "rpx_now"

  config.after_initialize do # so rake gems:install works
    RPXNow.api_key = "YOU RPX API KEY"


skip_before_filter :verify_authenticity_token, :only => [:rpx_token] # RPX does not pass Rails form tokens...

# user_data
# found: {:name=>'John Doe', :username => 'john', :email=>'[email protected]', :identifier=>''}
# not found: nil (can happen with e.g. invalid tokens)
def rpx_token
  raise "hackers?" unless data = RPXNow.user_data(params[:token])
  self.current_user = User.find_by_identifier(data[:identifier]) || User.create!(data)
  redirect_to '/'

# getting additional fields (these fields are rarely filled)
# all possibilities:
data = RPXNow.user_data(params[:token], :additional => [:gender, :birthday, :photo, :providerName, ...])

# including raw profile data
RPXNow.user_data(params[:token], :additional => [:raw])[:raw]['verifiedEmail']

# raw request processing
RPXNow.user_data(params[:token]){|raw| {:email=>raw['profile']['verifiedEmail']} }

# raw request with extended parameters (most users and APIs do not supply them)
RPXNow.user_data(params[:token], :extended=>'true'){|raw| ...have a look at the RPX API DOCS...}



RPXNow.api_version = 2

Mappings (PRX Plus/Pro)

You can map your primary keys (e.g. to identifiers, so that
users can login to the same account with multiple identifiers., primary_key) #add a mapping RPXNow.unmap(identifier, primary_key) #remove a mapping RPXNow.mappings(primary_key) # [identifier1,identifier2,...] RPXNow.all_mappings # [["1",['','']], ["2",[...]], ... ]

After a primary key is mapped to an identifier, when a user logs in with this identifier,
RPXNow.user_data will contain his primaryKey as :id.
A identifyer can only belong to one user (in doubt the last one it was mapped to)

User integration (e.g. ActiveRecord)

class User < ActiveRecord::Base
  include RPXNow::UserIntegration

user.rpx.identifiers == RPXNow.mappings( ==,
user.rpx.unmap(identifier) == RPXNow.unmap(identifier,

Contacts (PRX Pro)

Retrieve all contacts for a given user: RPXNow.contacts(identifier).each {|c| puts "#{c['displayName']}: #c['emails']}

Status updates (PRX Plus/Pro)

Send a status update to provider (a tweet/facebook-status/...) : RPXNow.set_status(identifier, "I just registered at ...")

Activity (RPX Plus/Pro)

Post a users activity, on their e.g. Facebook profile, complete with images, titels, rating, additional media, customized links and so on ... RPXNow.activity( identifier, :url=>href, :action=>'Im loving my new', :user_generated_content=>'Im loving my new ... ', :title=>product.title, :description=>product.description, :action_links=>[>>', :href=>product_url(product, :only_path => false)], :media=>[:src=>product.image_url, :href=>product_url(product, :only_path => false)] }


  • add provider / credentials helpers ?


rpx_now_gem mailing list


Michael Grosser
[email protected]
Hereby placed under public domain, do what you want, just do not hold me accountable...