我从昨天开始就忙于 Twitch API,有一个简单的身份验证工作,带有重定向 uri:
http://localhost:8000/redirect
现在我将重定向 uri 更改为:
http://localhost:8000/connect/twitch
它不再工作了。
我已经更改了 twitch 应用仪表板和请求中的 uri,但我仍然收到“Redirect_Mismatch”。
我做错了什么?
抽搐模型:
class Twitch{
var $client;
var $oauth_token;
public function __construct($token = null)
{
$this->client = new GuzzleHttp\Client();
if($token != null) $this->setOAuthToken($token);
}
public function retrieveOAuthToken($code)
{
$res = $this->client->post('https://api.twitch.tv/kraken/oauth2/token', [
'body' => [
'client_id' => Config::get('twitch.client_id'),
'client_secret' => Config::get('twitch.client_secret'),
'grant_type' => 'authorization_code',
'redirect_uri' => Config::get('twitch.redirect_uri'),
'code' => $code
],
'verify' => false
]);
$result = json_decode($res->getBody());
$this->oauth_token = $result->access_token;
}
}
Laravel Twitch 配置文件:
return array(
'client_id' => 'REMOVED',
'client_secret' => 'REMOVED',
'redirect_uri' => 'http://localhost:8000/twitch',
);
Controller :
class ConnectController extends \BaseController {
public function twitch()
{
$twitch = new Twitch();
$twitch->retrieveOAuthToken(Input::get('code'));
}
}
Twitch 应用设置:
最佳答案
你需要更新你的 laravel 配置:
return array(
'client_id' => 'REMOVED',
'client_secret' => 'REMOVED',
'redirect_uri' => 'http://localhost:8000/connect/twitch',
);
然后您通过 http://localhost:8000/connect/twitch 抽动重定向 URI .
如果 2 个 URL(Laravel 或 Twitch 设置)中的一个与另一个不同,您将拥有 Redirect_Mismatch
关于php - Twitch API redirect_mismatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28323717/