Skip to content

Instantly share code, notes, and snippets.

@subelsky
Created August 10, 2012 15:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subelsky/3315135 to your computer and use it in GitHub Desktop.
Save subelsky/3315135 to your computer and use it in GitHub Desktop.
How to create OmniAuth strategy aliases
# lib/omniauth-adwords-oauth2.rb
require "omniauth-google-oauth2"
class AdwordsOauth2 < OmniAuth::Strategies::GoogleOauth2
option :name, 'adwords_oauth2'
end
# config/initializers/omniauth.rb
require "omniauth-adwords-oauth2"
Rails.application.config.middleware.use OmniAuth::Builder do
provider :adwords_oauth2, ENV['GOOGLE_API_CLIENT_ID'], ENV['GOOGLE_API_CLIENT_SECRET'], {
scope: "https://adwords.google.com/api/adwords/" # could also be adwords-sandbox.google.com
}
end
OmniAuth.config.logger = Rails.logger
@mbleigh
Copy link

mbleigh commented Aug 11, 2012

You actually should be able to do this:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_oauth2, ENV['GOOGLE_API_CLIENT_ID'], ENV['GOOGLE_API_CLIENT_SECRET'], {
    scope: "https://adwords.google.com/api/adwords/" # could also be adwords-sandbox.google.com,
    name: :adwords_oauth2
  }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment