bignerdranch/omniauth-stable — pull request #4 by nybblr (2013-09-03 17:50:41+00:00)
Title: Add strategy to environment for controller use.

The OAuth2 strategy has several methods that need to be accessed in controllers. Notably, the `#client` method contains the initialized OAuth2 client needed to make requests with the settings passed in the initializer. Omniauth does something similar with `env['omniauth.strategy']` -- this provides `env['stable.strategy']` for use in controllers, e.g. in BNR-Percent:

~~~ruby
class ApplicationController < ActionController::Base
NoCurrentUser = Module.new

# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :authenticate!

private
# ...

def stable_client
env['stable.strategy'].client
end
end
~~~

This client can then be used to make requests by creating the `OAuth2::AccessToken` (which requires the client object.

Addresses #3
~ Jonathan