Core for all social media related functionality for Spree. The Spree Social gem handles authorization, account creation and association through social media sources such as Twitter and Facebook. This requires the edge source of Spree. This gem is beta at best and should be treated as such. Features and code base will change rapidly as this is under active development. Use with caution.
Add this extension to your Gemfile:
gem "spree_social", :git => "git://github.com/spree/spree_social.git"
Then run:
bundle update
rails g spree_social:install
bundle exec rake db:migrate
Preference(optional): By default url will be '/users/auth/:provider'. If you wish to modify the url to: '/member/auth/:provider', '/profile/auth/:provider', or '/auth/:provider' then you can do this accordingly in your config/initializers/spree.rb file as described below -
Spree::SocialConfig[:path_prefix] = 'member' # for /member/auth/:provider
Spree::SocialConfig[:path_prefix] = 'profile' # for /profile/auth/:provider
Spree::SocialConfig[:path_prefix] = '' # for /auth/:provider
Login as an admin user and navigate to Configuration > Social Authentication Methods
Click on the New Authentication Method button to enter the key obtained from their respective source (See below for instructions on setting up the various providers)
Multiple key entries can now be entered based on the rails environment. This allows for portability and the lack of need to check in your key to your repository. You also have the ability to enable and disable sources. These setting will be reflected on the client UI as well.
You MUST restart your application after configuring or updating an authentication method.
OAuth Applications @ Facebook, Twitter and / or Github are supported out of the box but you will need to setup applications are each respective site as follows for public use and for development.
All URLs must be in the form of domain.tld you may add a port as well for development
Facebook: https://developers.facebook.com/apps/?action=create
- Name the app what you will and agree to the terms.
- Fill out the capcha
- Under the Web Site tab
- Site URL: http://your_computer.local:3000 for development / http://your-site.com for production
- Site domain: your-computer.local / your-site.com respectively
Twitter: http://dev.twitter.com/apps/new
- Name and Description must be filled in with something
- Application Website: http://your_computer.local:3000 for development / http://your-site.com for production
- Application Type: Browser
- Callback URL: http://your_computer.local:3000 for development / http://your-site.com for production
- Default Access Type: Read & Write
- Save Application
Github: http://github.com/account/applications/new
- Name The Application
- Main URL: http://your_computer.local:3000 for development / http://your-site.com for production
- Callback URL: http://your_computer.local:3000 for development / http://your-site.com for production
- Click Create
This does not seem to be a listed Github item right now. To View and / or edit your applications goto http://github.com/account/applications/
- Google (OAuth)
git clone git://github.com/spree/spree
git clone git://github.com/spree/spree_social
cd spree
bundle install
bundle exec rake sandbox
add this to sandbox/Gemfile:
gem 'spree_social', :path => '../spree_social'
Then run:
bundle update
rails g spree_social:install
bundle exec rake db:migrate
Inside of your cloned spree_social folder, run:
bundle exec rake test_app
bundle exec rspec spec
Most auth sources supported by the Omniauth gem can be added. I attempt to keep the popular ones included and tested.
Copyright (c) 2012 John Brien Dilts, released under the New BSD License