Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

Undefined type LaravelPassportHasApiTokens when trying to implement OAuth2

I'm running a Laravel 8 project and I want to implement OAuth2. I successfully ran the following commands:

composer require laravel/ui --dev

php artisan ui vue --auth

composer require laravel/passport

php artisan migrate:refresh

php artisan passport:install

Then, I included Passport in the User model, like this:

<?php

namespace AppModels;

use IlluminateContractsAuthMustVerifyEmail;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;
use LaravelPassportHasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];
.
.
.

But, it shows me an Undefined type error when I include the HasApiTokens trait:

enter image description here

How can I solve this?

question from:https://stackoverflow.com/questions/65837358/undefined-type-laravel-passport-hasapitokens-when-trying-to-implement-oauth2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...