我想从TwitchTV OAuth API获取信息,授权效果很好,但我无法获取Twitch重定向到我的代码。
例如:
http://localhost/?code=noj4n39487fn29fn23v92hr293hnru23v97hre&scope=
This is how Twitch redirects back to my page. In the log of my rails server it also shows the following:
Started GET "/?code=q5yptiyx3cdaep52b7xyqgt3vjpwhg&scope=" for 371.1721.13.179 at 2015-08-22 17:09:26 +0200
Cannot render console from 315.127.134.179! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by HomeController#index as HTML
Parameters: {"code"=>"q5ypti345ferf2rf2efr2erferfe23ff", "scope"=>""}
News Load (0.6ms) SELECT "news".* FROM "news"
Rendered home/index.html.erb within layouts/home (14.7ms)
Completed 200 OK in 124ms (Views: 120.6ms | ActiveRecord: 1.0ms)
但是当我尝试在控制器中获取params.inspect
时,它会显示:
{"controller"=>"oauth", "action"=>"index"}
我的控制器看起来像这样:
class OauthController < ApplicationController
def index
redirect_to 'https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=34n87fn48fn438rzfghb4z8rofg4rg&redirect_uri=http://localhost/'
logger.info params.inspect
end
end
显然我改变了所有的ip,auth-codes和东西。我的问题是,params
不应该返回参数,因为它将它们显示为参数(在第一个代码块中)?
答案 0 :(得分:0)
Localhost是本地地址,'outworld'API无法将信息发送回'localhost',您必须使用http://127.0.0.1或为您的开发环境获取真实域名。