simsicon / weibo_2

A ruby gem for sina weibo oauth2 api, with examples, and it actually works.
MIT License
194 stars 86 forks source link

error working with devise omni-auth #9

Closed aisensiy closed 6 years ago

aisensiy commented 11 years ago
/Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/weibo_2-0.1.4/lib/weibo_2.rb:29:in `block (2 levels) in <class:Railtie>': undefined method `client_id' for nil:NilClass (NoMethodError)
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:25:in `each'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/weibo_2-0.1.4/lib/weibo_2.rb:27:in `block in <class:Railtie>'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/xushanchuan/projects/get-real/config/environment.rb:5:in `<top (required)>'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
    from /Users/xushanchuan/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
simsicon commented 11 years ago

Could you please give more information about this error? Thanks.

aisensiy commented 11 years ago

I want to integration devise omniauth and weibo_2 together. I follow the README and write

config.omniauth :weibo, Settings.WEIBO_KEY, Settings.WEIBO_SECRET, :scope => 'follow_app_official_microblog' 

in file config/initiallizers/devise.rb. But when i run command rails s in development environment. It show the errors above.

simsicon commented 11 years ago

Thanks, I will follow up this issue later.

icyleaf commented 10 years ago

It because Devise.omniauth_configs[:weibo].strategy is nil even all Devise.omniauth_configs. but you can fetch the key "args", check the Devise.omniauth_configs dump:

{
    :weibo => #<Devise::OmniAuth::Config:0x007fe10ddf0048 @provider=:weibo, @args=["cliend_id", "client_secret", {:scope=>"user,public_repo"}], @options={:scope=>"user"}, @strategy=nil, @strategy_name=:weibo, @strategy_class=nil>
}

Test env: rails 4.0 / devise 3.2.2 / omniauth-oauth-weibo2 0.3.0

simsicon commented 10 years ago

@icyleaf Thanks for updating this, would you like to open a pull to fix this?