Hi all, I've been trying to work with the Yahoo Contacts API using the latest version of Ruby OAuth, but I'm not sure if I'm getting hung up with the last stage of the authorization process, or something in the API. I hope you can help me figure that out.
Using the current version of OAuth, I'm able to apparently receive a working access key. I have a controller which requests the request_token like so:
I get an apparently good access token from this as well. It's only when I start using the API that things get pear-shaped.
# make initial contact so we get a contact ID yahoo_guid = @access_token.params[:xoauth_yahoo_guid] @response = @access_token.request(:post, 'http://social.yahooapis.com/ v1/user/' + yahoo_guid + '/contacts')
When I inspect the response body, I get this:
<?xml version=\"1.0\" encoding=\"utf-8\"?><error xmlns=\"http://social.yahooapis.com/v1/schema.rng\" xmlns:yahoo=\"http://www.yahooapis.com/v1/base.rng\" yahoo:uri=\"http://www.yahooapis.com/v1/errors/415\" yahoo:lang=\"en-US\"><description>Requested representation not available for the resource</description><detail>Invalid media type</detail></error>
I've seen in many places that there's some incompatibility between the Yahoo OAuth implementation and the Ruby OAuth gem. But I'm not sure if that information is out of date (I'm using the current 0.4.4).
Although this article is a little old, I wanted to just wanted to say thanks for the great starting point. I quickly realized that you were 99% of the way to success minus you used a ":post" instead of a ":get". If you were creating a new contact then you'd use a post, but since you were retrieving data you needed to use a get.
In addition, I leveraged oauth-plugin, which stores the access tokens for later use. Yahoo is one of those "special" cases where the access token expires after so much time (search around and people will tell you this until your ears bleed). The articles in Google kept leading me to believe that using oauth was not possible with Yahoo's API, but that is not actually true. I just had to add some handling around that concept and experiment with the configuration settings.