0

I want to use the Microsoft Translate API and I am already stuck obtaining the access token.

This is how my code looks like:

authUri = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/"
paramHash = {
  "client_id" => "test",
  "client_secret" => "*****",
  "scope" => "http://api.microsofttranslator.com",
  "grant_type" => "client_credentials"
}

postData = Net::HTTP.post_form(URI.parse(authUri), paramHash)
puts postData.body

But this won't terminate and after a while I get a Timeout Error:

`rescue in rbuf_fill': Timeout::Error (Timeout::Error)

I already tried the a Rest-Client gem and curl. Both worked perfectly fine, but I don't like incorporating another gem for such a simple task.

When I send the post request to localhost and listen with netcat I see the exact same requests (except for User-Agent, but even changing that didn't solve the problem)

flashpunk
  • 3
  • 3
  • read timeout? Check http://stackoverflow.com/questions/10011387/rescue-in-rbuf-fill-timeouterror-timeouterror – forker Jun 25 '13 at 22:44
  • Thank you for the answer, but the read_timeout is fine. The request doesn't take too long, so default value should be ok in this case – flashpunk Jun 26 '13 at 07:58

0 Answers0