-1. Get familiar with OmniAuth by Intridea: github.com/intridea/omniauth. Read about OAuth2.
-
Obtain client_id and client_secret for your app from Exvo.
-
Install exvo-auth gem or add it to your Gemfile.
-
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_secret"
-
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.
-
Include controller helpers into your application controller.
include ExvoAuth::Controllers::Rails (or Merb)
-
Implement callback(s).
Sample implementation in SessionsController:
def create
render :text => params[:auth].inspect
end
In short: you get params. Do what you want to do with it: store the data, create session, etc.
-
Read the source, there are few features not mentioned in this README.