Closed inetufo closed 12 years ago
I will try to test and fix this later, or would you like to try to fix it then pull request? ;-)
I just realized, did you set in your config/initiallizers/devise.rb like this?
config.omniauth :weibo, 'key', 'secret', :scope => 'user,public_repo'
我是这样设置了的: config.omniauth :weibo, AppSettings.weibo_token, AppSettings.weibo_secret, :scope => 'user,public_repo' 我怀疑是不是weibo_2.rb的这段代码 if Object.const_defined?("Devise") && Devise.omniauth_configs[:weibo] WeiboOAuth2::Config.api_key = Devise.omniauth_configs[:weibo].strategy.client_id WeiboOAuth2::Config.api_secret = Devise.omniauth_configs[:weibo].strategy.client_secret end 没有执行
I have tested this issue, and did not meet your problem, it works fine for me. Please confirm the below configs you did: 1, Add
devise :omniauthable
in your User model or other devise models.
2, Using the latest version of this gem, try this
gem 'weibo_2', '>= 0.1.1'
in your Gemfile.
3, You have get the authorization by calling the path
user_omniauth_authorize_path(:weibo)
and you have a proper way to handle the callback code. If you are not familiar this part, please take this example as ref.
I am closing this issue.
Yeah, i exactly did these steps you metioned, but it still reports the error without setting WeiboOAuth2::Config.api_key = YOUR_KEY WeiboOAuth2::Config.api_secret = YOUR_SECRET in environment.rb
My environment is nginx + passenger + rails3.2.8
Integrate with Devise and omniauth, if i don't put WeiboOAuth2::Config.api_key = YOUR_KEY WeiboOAuth2::Config.api_secret = YOUR_SECRET
in environment.rb file, then when i call
client = WeiboOAuth2::Client.new
NameError (uninitialized class variable @@api_key in WeiboOAuth2::Config) error occurs