首页 > 解决方案 > Google 服务“Oauth2”不存在或之前已被删除 - Composer

问题描述

我正在将 google oAuth 用于 Codeigniter 应用程序,并使用此作曲家库 "google/apiclient": "^2.10",进行登录,并且在本地环境中运行良好。但它下载了所有谷歌服务,我不想将所有不必要的库上传到服务器。所以我使用以下配置文件删除了所有内容。

composer.json file

{
"require": {
    "google/apiclient": "^2.10",
    "google/auth": "^1.16"
},
"scripts": {
    "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
},
"extra": {
    "google/apiclient-services": [
        "Drive",
        "YouTube"
    ]
}

}

但是后来我在身份验证时收到了应用程序的错误页面

An uncaught Exception was encountered Type: Error Message: Class "Google_Service_Oauth2" not found

所以我添加了适当的库"Oauth2" 并运行“composer update”命令。

{
"require": {
    "google/apiclient": "^2.10",
    "google/auth": "^1.16"
},
"scripts": {
    "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
},
"extra": {
    "google/apiclient-services": [
        "Drive",
        "YouTube",
        "Oauth2"
    ]
}

}

问题是 "Oauth2"库没有使用作曲家添加到现有项目中。

注意:我尝试过无线 "pre-autoload-dump": "Google\\Task\\Composer::cleanup"路更新,但仍然无法正常工作。

有没有办法使用作曲家文件或命令来解决这个问题。感谢您的帮助。

在此处输入图像描述

标签: phpcomposer-phpgoogle-oauthcodeigniter-3google-api-php-client

解决方案


谢谢社区,我刚刚找到了答案。

我必须删除apiclient-services完成的文件夹,然后需要运行 composer update 命令。

资源: IMPORTANT: If you add any services back in composer.json, you will need to remove the vendor/google/apiclient-services directory explicitly for the change you made to have effect:

google-api-php 客户端


推荐阅读