phpMick
2 months ago
523
8
General

API route guest access.

Posted 2 months ago by phpMick

Hi,

I am using Passport to protect my API. I want a route which can be accessed without authentication. How can I do this?

I thought that this would work but it returns Unauthenticated (in api.php):

Route::namespace('\\')->middleware('guest')->group(function () {
	
});

or

Route::namespace('\\')->group(function () {
	
});

I'm surprised at this because I thought that middleware('auth:api') had to be added to protect the routes?

auth.php

'api' => [
            'driver' => 'passport',
            'provider' => 'users',
            'hash' => false,
        ],

Cheers,

Mick

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