pelle / oauth-plugin

Rails plugin for OAuth
http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails
MIT License
716 stars 216 forks source link

retrieving credentials from ConsumerToken #71

Closed afeld closed 12 years ago

afeld commented 13 years ago

So inside of the TwitterToken#client method, I am getting the follow error when trying to authorize:

undefined local variable or method `credentials' for #<TwitterToken:0x420ce6ac>

I threw in some debugger statements and was strangely able to access credentials from within TwitterToken.consumer - i.e. only from the class but not from the instance. Any idea how I might get around this? I tried self.class.credentials, but no dice.

Rshomali commented 13 years ago

did you find out a solution for this ?

Thanks

afeld commented 13 years ago

havent looked at recent changes to ConsumerToken, but at the time i couldnt do it without patching the ConsumerToken itself. @pelle, thoughts?

joost commented 13 years ago

Put this in your consumer_token.rb:

  # Make credentials also available for objects.
  # Needed to make TwitterToken work.
  def credentials
    self.class.send(:credentials)
  end

OR create a twitter_token.rb model in your app and add self. on the line in the client method:

      if credentials[:client].to_sym==:oauth_gem