laravel-passport

Laravel Passport Route redirects to login page

倾然丶 夕夏残阳落幕 提交于 2020-03-13 03:35:35
问题 I'm using Laravel 5.3 & Passport. When using Postman to test any route I have set in api.php file it always returns the login page. Here is an example of my testing route: Route::get('/getKey', function() { return 'hello'; })->middleware('client_credentials'); Postman params: Accept application/json Authorization Bearer <then my key> I have set middleware to 'auth:api' per another solution I found while searching for the answer. protected function mapApiRoutes() { Route::prefix('api') -

Laravel Passport Route redirects to login page

瘦欲@ 提交于 2020-03-13 03:31:35
问题 I'm using Laravel 5.3 & Passport. When using Postman to test any route I have set in api.php file it always returns the login page. Here is an example of my testing route: Route::get('/getKey', function() { return 'hello'; })->middleware('client_credentials'); Postman params: Accept application/json Authorization Bearer <then my key> I have set middleware to 'auth:api' per another solution I found while searching for the answer. protected function mapApiRoutes() { Route::prefix('api') -

Laravel Passport always returns 401 Unauthenticated

半腔热情 提交于 2020-02-04 08:59:13
问题 I'm driving crazy! I've been searching around the web on thousands of StackOverFlow questions and haven't solved my issue. I'm developing an API REST with Laravel Framework 5.7 and Passport 7.0. I've setup every file following the documentation and I'm able to get a token with grant_type=password (without authentication flow), but when I try to access to a route protected by the auth:api middleware, I always get a 401 response. This is my HTTP request: GET /api/usuario/1/grupos HTTP/1.1 Host:

Laravel Passport always returns 401 Unauthenticated

元气小坏坏 提交于 2020-02-04 08:59:06
问题 I'm driving crazy! I've been searching around the web on thousands of StackOverFlow questions and haven't solved my issue. I'm developing an API REST with Laravel Framework 5.7 and Passport 7.0. I've setup every file following the documentation and I'm able to get a token with grant_type=password (without authentication flow), but when I try to access to a route protected by the auth:api middleware, I always get a 401 response. This is my HTTP request: GET /api/usuario/1/grupos HTTP/1.1 Host:

Laravel Passport custom validation for any /oauth/token request

限于喜欢 提交于 2020-01-24 19:52:29
问题 I need to validate extra fields in my users table before i create the requested tokens, but i can't find a simple way to do it with Passport . I find similar workarunds which returns a token using $user->createToken() but i can't find someone covering all default /oauth/token options like the refresh_token Also i see Passport have some simple ways to customize the username column and the password validation but i think this not cover my neededs. Update Im not sure if this is the best solution

Laravel Passport custom validation for any /oauth/token request

霸气de小男生 提交于 2020-01-24 19:52:04
问题 I need to validate extra fields in my users table before i create the requested tokens, but i can't find a simple way to do it with Passport . I find similar workarunds which returns a token using $user->createToken() but i can't find someone covering all default /oauth/token options like the refresh_token Also i see Passport have some simple ways to customize the username column and the password validation but i think this not cover my neededs. Update Im not sure if this is the best solution

Vue SPA + laravel Passport: how to authenticate properly? [closed]

流过昼夜 提交于 2020-01-23 03:06:03
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 7 days ago . I'm trying to figure out what's the correct way to authenticate users with Passport for a Vue SPA. I can't figure out which grant type I should use considering that implicit grant is not recommended by IETF’s OAuth working group and the other methods require to pass the client

Disable Laravel CSRF Protection for /api routes when consuming API with JavaScript

我是研究僧i 提交于 2020-01-22 02:49:08
问题 I have a Laravel backend, and React frontend. For development, React runs on localhost:3000 and Laravel on localhost:8080 , so I had to allow Cors. I have set up Passport successfuly and am able to Consume my API with JavaScript. But on every request, I have to include the X-CSRF-TOKEN to access protected API routes, which works, but for development I'd like to disable CSRF-Protection for the API. I already tried to add the /api route to the except array in VerifyCsrfToken and removed the

How to add custom field to laravel passport client model and check it

时间秒杀一切 提交于 2020-01-16 17:26:46
问题 Laravel passport Client model has this fields on oauth_clients table: name secret redirect personal_access_client password_client revoked And how I can add my custom filed request_domain_name to client credentials for check requesting domain name with this custom field value on every request? 回答1: You can create a separate migration php artisan make:migration alter_oauth_clients_table_request_domain_name --table=oauth_clients and inside your migration define new column Schema::table('oauth

Laravel/Passport Do I really need to register Passport::routes() for a simple CRUD API?

一笑奈何 提交于 2020-01-15 10:26:49
问题 I registered Passport::routes(); in the boot method of AuthServiceProvider, but I don't seem to be using any of the routes it registers. Do I need them? What are they used for? Can't I just use my custom routes that map to a custom controller for login, register and logout methods? 回答1: (EDITED) No, you do not need to register Passport::routes() in AuthServiceProvider if you don't use them. The following custom controller logic (adapted from https://medium.com/techcompose/create-rest-api-in