This is based on the SoAuth projects. See http://www.octolabs.com/so-auth for more details.
clickfunnels_auth to the
Generate an initializer
Run this command
rails generate clickfunnels_auth:install
This will create the following files
Create a new application in your main
Clickfunnels mothership instance
Go to the
/oauth/applications endpoint on the
installation that you want to integrate with. For development this will
Create a new application, and set the callback URL to
http://localhost:3001/auth/clickfunnels/callback. Change the port if you
plan to run your client app on a different port. (See the optional
After creating the app make note of the Application Id and the Secret.
Set some environment variables for your client
In your new client project (where you installed this gem), you should
set some environment variables. Using something like
probably the best so that you can just set them in a
AUTH_PROVIDER_URL=http://localhost:5000 AUTH_PROVIDER_APPLICATION_ID=1234 AUTH_PROVIDER_SECRET=5678 AUTH_PROVIDER_ME_URL=/api/me.json
Be sure to use the Application Id you got in the last step as
AUTH_PROVIDER_APPLICATION_ID and the Secret as
If you haven't already done it, you should create a
rails generate model user email:string
Then be sure to run migrations.
rake db:migrate; rake db:test:prepare
ApplicationController to inherit from
ClickfunnelsAuth::ApplicationController. The first line should look like this.
class ApplicationController < ClickfunnelsAuth::ApplicationController
Protect some stuff in a controller
before_filter to protect some controller actions.
OPTIONAL : Change the default port of your new project
Since we're relying on
clickfunnels_auth_provider to provide authentication, we need
to run our new project on a different port in development. Open up
and add this to the bottom of the file. If you want to use a port other
3001 just change the port as appropriate.
# Setting default port to 3001 require 'rails/commands/server' module Rails class Server alias :default_options_alias :default_options def default_options default_options_alias.merge!(:Port => 3001) end end end
Or you could just run your development server on a different port:
rails s -p 3001
unicorn -p 3001 -c ./config/unicorn.rb
This project rocks and uses MIT-LICENSE.