Post

omniauthのTwitterプロバイダーのoptionsを動的に変更する

SETUP_PROC = lambda do |env| request = Rack::Request.new(env) user = User.find_by_subdomain(request.subdomain) env['omniauth.strategy'].options[:client_id] = user.consumer_key # if using omniauth-oauth2 env['omniauth.strategy'].options[:client_secret] = user.consumer_secret # if using omniauth-oauth2 env['omniauth.strategy'].options[:consumer_key] = user.consumer_key # if using omniauth-oauth env['omniauth.strategy'].options[:consumer_secret] = user.consumer_secret # if using omniauth-oauth end use OmniAuth::Builder.new do provider :twitter, setup: SETUP_PROC, callback_path: "/path/to/callback", image_size: "original" end

Setup Phase · omniauth/omniauth Wiki · GitHub

This post is licensed under CC BY 4.0 by the author.