我試圖用護照使用的OAuth /授權,以允許Web應用程序以獲取代碼,後來請求令牌,但我得到的錯誤Laravel護照的OAuth /授權錯誤
路線[登錄]未定義
以下是我的代碼。
客戶端代碼
// First route that user visits on consumer app
Route::get('/', function() {
// Build the query parameter string to pass auth information to our request
$query = http_build_query([
'client_id' => 3,
//'client_secret' => 'MtkEmBL0f0Bf4LcEPcOBUS0wLHvF5xqqchhCpaTH',
'redirect_uri' => 'http://client.app:8082/callback',
'response_type' => 'code',
'scope' => ''
]);
// Redirect the user to the OAuth authorization page
return redirect('http://server.app:8082/oauth/authorize?' . $query);
});
// Route that user is forwarded back to after approving on server
Route::get('/callback', function (Request $request) {
return 'test 2';
$http = new GuzzleHttp\Client;
$response = $http->post('http://server.app:8082/oauth/token', [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => 3, // from admin panel above
'client_secret' => 'MtkEmBL0f0Bf4LcEPcOBUS0wLHvF5xqqchhCpaTH', // from admin panel above
'redirect_uri' => 'http://client.app:8082/callback',
'code' => $request->code // Get code from the callback
]
]);
// echo the access token; normally we would save this in the DB
return json_decode((string) $response->getBody(), true)['access_token'];
});
Accept頭你在哪裏定義權威性路線? –
嗨shukshin!我的路由在AuthServiceProvider File中定義,如下圖所示。Passport :: routes(); –