PHP Laravel Passport - /oauth/tokens 401 Unauthorized

Posted 7 months ago by oliverbusk

I am currently trying to create a SPA application that uses Laravel. However with this application, I also need to be able for other applications to interact with it.

This is my boilerplate, and I have just made a fresh install.

After installing this, I can successfully login my SPA. I then want to be able to administer tokens, to issue to 3rd party applications. To do this, I follow the official documentation for Laravel Passport.

I've registered the Vue components as mentioned in the documentation, and they also do show up in my app. However, for some reason they contain a lot of "empty" clients and tokens:

Empty Clients

Empty Tokens

Checking my console, I see that I can't even access the /oauth/*:

Errors

This is my AuthServiceProvider.php:

public function boot()
{
    $this->registerPolicies();

    Passport::routes(function ($router) {
        $router->forAccessTokens();
    });
}

This is my routes/api.php:

Route::middleware('auth:api')->group(function () {
    Route::get('/user', function (Request $request) {
        return $request->user();
    });
});

Please note, I can successfully log in / out of the "main" application. I just can't create new clients/tokens, so I can access my API from other applications.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.