Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 2.42 KB

README.md

File metadata and controls

38 lines (30 loc) · 2.42 KB

omniauth-demo

Based on the Quinton Wall's tutorial and utilizing Richard Vanhook's omniauth-salesforce, this is an update to this popular example running with Rails 3.1.3 with the following gems; oauth2 (0.5.2), omniauth (1.0.2), omniauth-oauth2 (1.0.0), omniauth-salesforce (1.0.3) and httparty (0.8.1). Thanks to Quinton and Richard for their great work on these projects. Here are some brief instructions on how to use it;

  1. Clone this repo to your development environment.
  2. Create .key and .crt files as per this article.
  3. Create the directory lib/certs and copy the .key and .crt files from the previous step to it.
  4. Configure WEBrick so it supports HTTPS using this article as a guide. Don't forget to modify the generic paths so they point to the .key and .crt files you created above.
  5. Create and then modify config/omniauth.yml as shown below so that it has your Salesforce key and secret, changing the placeholders to your actual key and secret.
  6. Make sure the Salesforce account to which these keys are related has REST enabled!
  7. Start WEBrick with rails server while in the root directory of your project.
  8. Point browser to https://localhost:3000
  9. Click 'auth/salesforce' link
  10. You should be redirected to Salesforce login page, to which you enter your credentials.
  11. Approve access by the application.
  12. When returned to the home page, you should now see the Auth token
  13. Click on the '/accounts' link.
  14. You should see the dump of the Account information.

To see Oauth refresh token in action:

  1. Login to Salesforce ... Navigate to 'Administration Setup > Security Controls > Session Settings
  2. Set session timeout to shortest (15 min.)
  3. Start / restart this demo app ... follow steps 8 - 14 above to get Account data.
  4. Wait longer than session timeout (15 min.).
  5. Refresh account page. You will get renewed display of account data.
  6. Look at server log ... see refresh token flow.

omniauth.yml

# simple omniauth.yml configuration file
key: <key>
secret: <secret>

Any questions comments, please don't hesitate to get in touch. The best way is likely to be Twitter @IntellogInc.