oAuth Plugin with Yelp 2.0 Business API

92 views
Skip to first unread message

Ben Densmore

unread,
Apr 3, 2012, 12:04:09 PM4/3/12
to oauth...@googlegroups.com
I'm hoping someone can point me in the right direction here. 

I've successfully implemented the oAuth plugin in rails to connect to google and picwing just for testing purposes and to make sure I understand how the plugin works. I'm now trying to grant access to my Yelp account and can't seem to figure out what their API needs for me to communicate with it correctly.

The other APIs I've implemented give you the request token url, access token url and authorize url which makes it super easy to copy and paste those into a hash with those key/value pairs.

Yelp seems to want you to send over a bunch of other info which the oAuth plugin doesn't seem to support? at least not from what I can find.

Here is an example of connecting to picwing which I was able to gain access to with no issues.

initializers/oauth_consumers.rb

OAUTH_CREDENTIALS={
:picwing => {
:key => "mykey",
:secret => "mysecret"
}
}

then in my user model I add:
has_one :picwing, :class_name => "PicwingToken", :dependent => :destroy

and then I create a subclass called PicwingToken with the following:

class PicwingToken < ConsumerToken
PICWING_SETTINGS = {
        :site=>"http://www.picwing.com",
        :authorize_url =>"http://www.picwing.com/oauth/authorize",
        :request_token_url => "http://www.picwing.com/oauth/request_token",
        :access_token_url => "http://www.picwing.com/oauth/access_token"
}

def self.consumer(options={})
@consumer ||= OAuth::Consumer.new(credentials[:key], credentials[:secret], PICWING_SETTINGS.merge(options))
end
end


Where I'm getting lost is when I create a YelpToken subclass I'm not sure what info needs to be in the YELP_SETTINGS hash. I've tried just doing the following but I always get a 404 error when I do http://localhost:3000/oauth_consumers/yelp:

  YELP_SETTINGS = {
      :scheme => :header,
      :http_method => :post 
 }

Has anyone worked with the Yelp API and might be able to show me what they passed in to the Consumer?

Thank you,
Ben


Reply all
Reply to author
Forward
0 new messages