A gem to automatically go out and grab new access tokens when making oauth calls. Then storing them in a yml file for later use and reference.
Add this line to your application's Gemfile:
gem 'oauthorizer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install oauthorizer
Create a file in config/initializers/oauthorizer.rb
oauthorizer_keys = YAML.load_file(File.join(Rails.root, 'config', 'oauthorizer_config.yml'))
Rails.application.config.middleware.insert_before ActionDispatch::Static, Rack::Oauthorizer, oauthorizer_keys
Create a config file in your config directory.
google: client_id: client_secret: scope: https://www.googleapis.com/auth/latitude.all.best+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email redirect_uri: http://localhost:3030/callbacks/google.json server_port: 3030 user_email: user_password: facebook: client_id: client_secret: scope: publish_checkins redirect_uri: http://localhost:3030/callbacks/facebook.json server_port: 3030 state: stuff user_email: user_password: foursquare: client_id: client_secret: redirect_uri: http://localhost:3030/callbacks/foursquare.json server_port: 3030 user_email: user_password:
Make sure that the port in your redirect_uri matches your server_port.
You must fill in information for the client_id, client_secret, user_email and password. The user email and password should be for a test account that you have setup.
In your spec simply initialize Oauthorizer then set a variable for the token.
oauther = Oauthorizer::Token.new token = oauther.get_google_token_hash token = oauther.get_facebook_token_hash token = oauther.get_foursquare_token_hash
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request