Laravel Passport:成功登录后的Displayusername

时间:2017-05-02 05:43:31

标签: javascript php laravel laravel-passport

我目前正在使用Laravel 5.4,我尝试按照https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13部署Passport进行练习。成功授权后,它将返回客户端站点上的Json output。但我没有想要在另一个view 'logged'中显示欢迎消息**的用户名。基本问题是如何从服务器中提取用户名。我见过提供基本用户信息的fb / twitter,我试图复制它。 任何想法我怎样才能做到这一点? 如果需要任何其他信息,我可以提供 我的web.php

    use Illuminate\HTTP\Request;

    Route::get('/', function () {
        return view('welcome');
    });



    Route::get('/log', function () {
        $query = http_build_query ([
            'client_id' => 9,
            'redirect_uri' => 'http://127.0.0.1:8991/callback',
            'response_type' => 'code',
            'scope' => '', ]);

        return redirect('http://127.0.0.1:8081/oauth/authorize?'.$query);
        });


    Route::get('/callback', function (Illuminate\Http\Request $request) {
        $http = new GuzzleHttp\Client;

        $response = $http->post('http://127.0.0.1:8081/oauth/token', [
            'form_params' => [
            'client_id' => 9,
            'client_secret' => 'Y0XV42feEZ5xurwUwaAs46PzgvsLGoghUfgfRUId',
            'grant_type' => 'authorization_code', 
            'redirect_uri' => 'http://127.0.0.1:8991/callback',
            'code' => $request->code,
            ],

        ]);

            return json_decode((string) $response->getBody(), true);
            //return view('logged');

    });     

0 个答案:

没有答案