Hi all
I’m getting a ‘Connection reset by peer’ while getting an access token
during oAuth from a third party API. Here’s the code snippet:
def accesstoken
@code = params[:code]
url = URI.parse(‘access token request url’)
req = Net::HTTP::Post.new(url.path)
req.set_form_data({‘auth_code’ => @code, ‘client_id’=>‘my_client_id’,
‘client_secret’=>‘my_secret_key’}, ‘;’)
res = Net::HTTP.new(url.host, url.port).start { |http|
http.request(req) }
case res
when Net::HTTPSuccess, Net::HTTPRedirection
# OK
else
# res.error!
end
render :text => @code.inspect
end
I get a valid authorization code but unable to proceed to get access
token due to above error. The third party API has to return a response
in json format.
Any help is much awaited and appreciated!