public function createToken($name, array $scopes = [])
    {
        // Backup default provider
        $defaultProvider = config('auth.guards.api.provider');

        $userProvider = AuthConfigHelper::getUserProvider($this);

        // Change config to when the token is created set the provider from model creating the token.
        config(['auth.guards.api.provider' => $userProvider]);

        $token = Container::getInstance()->make(PersonalAccessTokenFactory::class)->make(
            $this->getKey(), $name, $scopes
        );

        // Reset config to defaults
        config(['auth.guards.api.provider' => $defaultProvider]);

        return $token;
    }