What are you trying to do? Use passport inside your application or from an external application?
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.
I’m not sure I have ever heard of it . Where are you seeing people use it ?
OK i understand now, it works only when you have a relation in place: https://stackoverflow.com/questions/46673667/laravel-passport-api-retrieve-authenticated-token
Strange that Laravel does not allow us to retrieve a user token with a default functions created by their team.
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'); }
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community