laravel-passport

Passport - “Unauthenticated.” - Laravel 5.3

浪尽此生 提交于 2019-11-27 16:07:07
问题 I hope someone could explain why I'm unauthenticated when already has performed a successfull Oauth 2 authentication process. I've set up the Passport package like in Laravel's documentation and I successfully get authenticated, receives a token value and so on. But, when I try to do a get request on, let say, /api/user , I get a Unauthenticated error as a response. I use the token value as a header with key name Authorization , just as described in the docs. Route::get('/user', function

Get user data using access token in laravel passport client app

心不动则不痛 提交于 2019-11-27 13:16:14
I have successfully created server.app and client.app using Laravel Passport documentation . Everything works as expected. client.app Route: Route::get('callback', function (Request $request) { $http = new GuzzleHttp\Client; $response = $http->post('http://server.app/oauth/token', [ 'form_params' => [ 'grant_type' => 'authorization_code', 'client_id' => 3, 'client_secret' => 'secret', 'redirect_uri' => 'http://client.app/callback', 'code' => $request->code ] ]); return json_decode((string) $response->getBody(), true)['access_token']; }); By default, this route returns access_token , with which

Laravel Passport vs JWT vs Oauth2 vs Auth0

旧城冷巷雨未停 提交于 2019-11-27 10:56:26
问题 Confusion about API auth types in Laravel? I'm currently learning how to create an API in Laravel and I found myself into this confusing concepts. After a few days of research and practice, I could finally understand enough this concepts to make a mini-guide. I had to look into a lot of separate webpages so I will make my best attempt to explain the relationship between them. 回答1: What are these concepts? Passport is an official Laravel package that implements Oauth2 and JWT. Auth0 is an

Laravel Passport Scopes

不问归期 提交于 2019-11-27 03:12:26
I am a bit confused on the laravel scopes part. I have a user model and table. How can I assign a user the role of user, customer and/or admin. I have a SPA with vue and laravel api backend. I use https://laravel.com/docs/5.3/passport#consuming-your-api-with-javascript Passport::tokensCan([ 'user' => 'User', 'customer' => 'Customer', 'admin' => 'Admin', ]); How can i assign which user model has which scope(s)? Or are scopes not the same as roles? How would you implement this? Thanks in advance! Or are scopes not the same as roles? The biggest difference between the two is the context they

How to use Laravel Passport with a custom username column

你离开我真会死。 提交于 2019-11-26 19:57:35
问题 Now I'm using something like that for authenticating the user on my base site: if (Auth::attempt($request->only(['id', 'password']))) { // } How can I modify this code for using custom column as username? https://laravel.com/docs/5.3/passport#password-grant-tokens 回答1: You can use findForPassport method in your user model. This method take username as argument, and return user model For example: class User extends Authenticatable { use HasApiTokens, Notifiable; // ... some code public

Laravel Passport Scopes

↘锁芯ラ 提交于 2019-11-26 12:54:26
问题 I am a bit confused on the laravel scopes part. I have a user model and table. How can I assign a user the role of user, customer and/or admin. I have a SPA with vue and laravel api backend. I use https://laravel.com/docs/5.3/passport#consuming-your-api-with-javascript Passport::tokensCan([ \'user\' => \'User\', \'customer\' => \'Customer\', \'admin\' => \'Admin\', ]); How can i assign which user model has which scope(s)? Or are scopes not the same as roles? How would you implement this?

Laravel 5.6 - Passport JWT httponly cookie SPA authentication for self consuming API?

99封情书 提交于 2019-11-26 10:30:45
NOTE: I had 4 bounties on this question, but non of the upvoted answers below are the answer needed for this question. Everything needed is in Update 3 below, just looking for Laravel code to implement. UPDATE 3: This flow chart is exactly the flow I am trying to accomplish, everything below is the original question with some older updates. This flow chart sums up everything needed. The green parts in the flow chart below are the parts that I know how to do. The red parts along with their side notes is what I am looking for help accomplishing using Laravel code. I have done a lot of research

Laravel 5.6 - Passport JWT httponly cookie SPA authentication for self consuming API?

冷暖自知 提交于 2019-11-26 02:09:01
问题 NOTE: I had 4 bounties on this question, but non of the upvoted answers below are the answer needed for this question. Everything needed is in Update 3 below, just looking for Laravel code to implement. UPDATE 3: This flow chart is exactly the flow I am trying to accomplish, everything below is the original question with some older updates. This flow chart sums up everything needed. The green parts in the flow chart below are the parts that I know how to do. The red parts along with their