3
votes

Need some help, please.

I followed the tutorial What's New in Laravel 5.3: Laravel Passport (https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13) step by step and i have this error:

ServerException in RequestException.php line 107: Server error: POST http://latest.dev/oauth/token resulted in a 500 Internal Server Error response: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'consumer.oauth_clients' doesn't exist (SQL: select * from `oa (truncated...)

consumer.dev

use Illuminate\Http\Request;

Route::get('/', function () {

    $query = http_build_query([
        'client_id'     => 4,
        'redirect_uri'  => 'http://consumer.dev/callback',
        'response_type' => 'code',
        'scope'         => '',
    ]);
    return redirect('http://latest.dev/oauth/authorize?'.$query);
});

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

    $response = $http->post('http://latest.dev/oauth/token', [
        'form_params'   => [
            'grant_type'        => 'authorization_code',
            'client_id'         => 4,
            'client_secret'     => 'a8OifFPH38rMi1I6vjmV3O8XD55hAk2FG4f95j9W',
            'redirect_uri'      => 'http://consumer.dev/callback',
            'code'              => $request->code,
        ],
    ]);
    return json_decode((string) $response->getBody(), true);
});
1
Can you confirm that you have checked that you have the migrations needed for passport and that you ran artisan migrate?tam5
@tam I followed the exact same steps on consumer.dev project: composer require laravel/passport, migrate, passport:install. Basically, create two almost identical projects. Now it's working fine. It solved my problem but I don't know if is the best solution. Taylor should explain what tables we need to create on the consumer.dev project (for beginners like me). Wee need the same tables on both projects? We need to follow the same steps? Thank you!confm
I had problem like you.. have you solve it ?Daniel Listyo Emanuel
@DanielListyoEmanuel Follow the same steps on consumer.dev, than migrate. If you create the same tables for both projects (oauth_clients, oauth_access_tokens etc.) it's working.confm

1 Answers

0
votes

Run the following command

php artisan serve

and replace the URL links to new URLs created by the artisan serve command.
And try again - then it will work.