Sha256: 48fb825b837208ca4ab6f13ace65a65c153677319f695ad4080e3e44cd91e56f
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
-1. Get familiar with OmniAuth by Intridea: http://github.com/intridea/omniauth. Read about OAuth2. 0. Obtain client_id and client_secret for your app from Exvo. 1. Install exvo-auth gem or add it to your Gemfile. 2. Configure middleware(s). There are two middlewares. Usually you will need the "interactive" one: ExvoAuth::Strategies::Interactive ExvoAuth::Strategies::NonInteractive Both middlewares need client_id and client_secret arguments. In Rails, the relevant line could look like this: config.middleware.use ExvoAuth::Strategies::Interactive, :client_id => "client_id, :client_secret => "client_secret" 3. Add routes. The following comes from Rails config/routes.rb file: match "/auth/failure" => "sessions#failure" match "/auth/interactive/callback" => "sessions#create" match "/auth/non_interactive/callback" => "sessions#create" Failure url is called whenever there's a failure (d'oh). You can have separate callbacks for interactive and non-interactive callback routes but you can also route both callbacks to the same controller method like shown above. 4. Include controller helpers into your application controller. include ExvoAuth::Controllers::Rails (or Merb) 5. Implement a sessions controller. Sample implementation (Rails): class SessionsController < ApplicationController def create auth = params[:auth] user = User.find_or_create_by_uid(auth["uid"]) user_info = auth["user_info"] user.update_attributes!(user_info) sign_in_and_redirect!(user.id) end def destroy sign_out_and_redirect! end def failure render :text => "Sorry!" end end In short: you get params[:auth]. Do what you want to do with it: store the data, create session, etc. 6. Read the source, there are few features not mentioned in this README.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exvo-auth-0.5.2 | README |