Support the ongoing development of Laravel.io →
posted 5 years ago
Laravel
Last updated 1 year ago.
0

What are you trying to do? Use passport inside your application or from an external application?

0

Thank you for the reply. The problem for me is not the logic in itself as I can create a logout and login api, what I am not understanding is where the other devs get this from for Laravel 5.7:

Auth::user()->accessTokens();

As I cannot find it from here: https://laravel.com/api/5.7/Illuminate/Auth/Authenticatable.html

I actually cannot find accessTokens() anywhere in the api doc when added to the search bar on that website.

Would you mind pinpointing me to the right direction?

Let's say I have Auth::user()-> , how do I know that accessTokens() is the property used in Laravel 5.7 to get the user access token? I am always relying on posts from others to find these methods but would really like to know how they find them in the first place.

Thanks.

0

I’m not sure I have ever heard of it . Where are you seeing people use it ?

0

OK i understand now, it works only when you have a relation in place: https://stackoverflow.com/questions/46673667/laravel-passport-...

Strange that Laravel does not allow us to retrieve a user token with a default functions created by their team.

0

No need for relations, this guy here explains it: https://youtu.be/HGh0cKEVXPI?t=1401

It is found in the hasApiTokens.php which is in the user model. public function tokens() { return $this->hasMany(Passport::tokenModel(), 'user_id')->orderBy('created_at', 'desc'); }

0

Sign in to participate in this thread!

Eventy

Your banner here too?

bennyboy benoit1980 Joined 10 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.