1
votes

I have 2 servers , an laravel API and an Auth server with passport. The authentication server generates the access token normally , i'm using client credentials.

When i try to protect my routes in API using the middleware auth:api or client , where it is defined on Kernel.php it returns me 401 Unauthenticated the API dont read the token correctly.

My route in the API

Route::middleware('client')->group(function () {

    Route::resource('invoice' , 'InvoiceController')->middleware('scopes:x');

});

It returns 401, and the same route in Auth server works perfectly.

1
Are you using the same oauth keys for both servers? - Brian Lee
Yes, for testing purposes. But the correct flow is: the Passport server generates the token and the API read it. - Raphael Oliveira
I meant the signing keys, the ones generated by php artisan passport:keys - Brian Lee
Probably not , how i do that ? Use the same keys for the servers ? - Raphael Oliveira

1 Answers

1
votes

Tokens are signed... with the Oauth keys... Use the same in both servers and that's all you need I think...

On one server you need keys... so

php artisan passport:keys

That generates the keys in the storage directory by default: Storage directory with encryption keys

Then just copy those keys to the other server... the signature/encrpytion will then be the same in both servers...