Geting access token from stackoverflow api in rails

时间:2016-10-09 15:54:17

标签: ruby-on-rails ruby stackexchange-api

i am getting the access token from stack overflow api by POST (application/x-www-form-urlencoded) request as

curl --data "client_id=8020&client_secret=ROsccJrTR7k5AkiJelWg((&code=6cKnhU8IxyOAjJKgiVhHbA))&redirect_uri=http://localhost:5000/social/stackoverflow_redirect" https://stackexchange.com/oauth/access_token

but i want to do the same thing in my ruby code so i am implementing in rails application by Net:HTTP but i am not able to get the same response as i was getting in curl request.

Net::HTTP::Post.new('https://stackexchange.com/oauth/access_token',{client_id: '8020',client_secret: 'ROsccJrTR7k5AkiJelWg((&code=6cKnhU8IxyOAjJKgiVhHbA))',code: params['code'],redirect_uri: 'http://localhost:5000/social/stackoverflow_new'})

please tell me how can i get the same response through Net:HTTP in rails.

0 个答案:

没有答案