Raphael Oliveira
Raphael Oliveira

Reputation: 35

Laravel API aren't reading access token from another server

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.

Upvotes: 1

Views: 1059

Answers (1)

Serge
Serge

Reputation: 2187

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...

Upvotes: 1

Related Questions