首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel护照oauth/授权错误

Laravel护照oauth/授权错误
EN

Stack Overflow用户
提问于 2017-09-10 20:16:21
回答 2查看 3.8K关注 0票数 2

我正在尝试使用Passport使用oauth/authorize,以便允许web应用程序稍后获取代码和请求令牌,但我得到了错误

未定义路由登录

下面是我的密码。

客户端代码

代码语言:javascript
复制
    // 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'];
});

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-09-10 22:38:33

也许你有不止一个错误。看来你忘了定义普通的奥斯丁路线了。从php artisan make:authAuth::routes()开始。OAuth路由没有login路由,您得到的错误表明您没有定义login路由。它实际上是在Auth::routes()中定义的。

票数 2
EN

Stack Overflow用户

发布于 2018-01-31 02:58:54

我也有同样的问题,很明显,我并没有在请求中传递接受头

代码语言:javascript
复制
Accept:application/json
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46145166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档